Example usage for com.google.gson.internal.bind TypeAdapters newTypeHierarchyFactory

List of usage examples for com.google.gson.internal.bind TypeAdapters newTypeHierarchyFactory

Introduction

In this page you can find the example usage for com.google.gson.internal.bind TypeAdapters newTypeHierarchyFactory.

Prototype

public static <T1> TypeAdapterFactory newTypeHierarchyFactory(final Class<T1> clazz,
        final TypeAdapter<T1> typeAdapter) 

Source Link

Document

Returns a factory for all subtypes of typeAdapter .

Usage

From source file:no.uis.service.ws.studinfosolr.impl.SolrUpdaterImpl.java

License:Apache License

@PostConstruct
public void init() {
    GsonBuilder builder = new GsonBuilder();
    if (typeAdapters != null) {
        for (Map.Entry<Class<?>, TypeAdapter<?>> adapter : typeAdapters.entrySet()) {
            builder.registerTypeAdapter(adapter.getKey(), adapter.getValue());
        }//w w w .j  a  v a 2 s.  c om
        // for <any/> element
        builder.registerTypeAdapterFactory(
                TypeAdapters.newTypeHierarchyFactory(ElementImpl.class, new XmlElementAdapter()));
    }
    gson = builder.create();
    StringConverterUtil.registerConverter(new InngarIStudieprogramConverter(), InngarIStudieprogram.class);
    StringConverter collectionConverter = new CollectionConverter();
    StringConverterUtil.registerConverter(collectionConverter, List.class);
    StringConverterUtil.registerConverter(collectionConverter, Set.class);
    StringConverterUtil.registerConverter(new ObligoppgaveConverter(), Obligoppgave.class);
}