Example usage for com.google.gson TypeAdapterFactory interface-usage

List of usage examples for com.google.gson TypeAdapterFactory interface-usage

Introduction

In this page you can find the example usage for com.google.gson TypeAdapterFactory interface-usage.

Usage

From source file funf.config.SingletonTypeAdapterFactory.java

/**
 * Same configuration should return the same object.  
 * A cache of each object created is kept to ensure this.
 * 
 * TODO: should probably have weak refs, so that we can garbage collect unused items.
 * 

From source file gobblin.util.io.GsonInterfaceAdapter.java

/**
 * A {@link Gson} interface adapter that makes it possible to serialize and deserialize polymorphic objects.
 *
 * <p>
 *   This adapter will capture all instances of {@link #baseClass} and write them as
 *   {"object-type":"class.name", "object-data":"data"}, allowing for correct serialization and deserialization of

From source file io.barracks.ota.client.UpdateCheckService.java

/**
 * This service is used to handle the request to the barracks service in the background.<br>
 * It uses the {@link LocalBroadcastManager} to send updates about the request, using the categories
 * for {@link UpdateCheckService#UPDATE_AVAILABLE an available update},
 * {@link UpdateCheckService#UPDATE_UNAVAILABLE no update available} and
 * {@link UpdateCheckService#UPDATE_REQUEST_ERROR failure} for a defined {@link UpdateCheckService#ACTION_CHECK action}

From source file io.github.rcarlosdasilva.weixin.core.json.CustomTypeAdapterFactory.java

public class CustomTypeAdapterFactory implements TypeAdapterFactory {

    @SuppressWarnings("unchecked")
    @Override
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        Class<? super T> clazz = type.getRawType();

From source file io.hops.hopsworks.api.zeppelin.json.NotebookTypeAdapterFactory.java

/**
 * Custom adapter type factory
 * Modify the jsonObject before serailaization/deserialization
 * Check sample implementation at  {@link NotebookServer}
 * @param <C> the type whose json is to be customized for serialization/deserialization
 */

From source file io.prediction.workflow.JavaQueryTypeAdapterFactory.java

public class JavaQueryTypeAdapterFactory implements TypeAdapterFactory {
    @Override
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        if (type.getRawType().equals(JavaQuery.class)) {
            return (TypeAdapter<T>) new TypeAdapter<JavaQuery>() {
                public void write(JsonWriter out, JavaQuery value) throws IOException {

From source file it.polimi.ingsw.GC_29.Controllers.RuntimeTypeAdapterFactory.java

/**
 * Adapts values whose runtime type may differ from their declaration type. This
 * is necessary when a field's type is not the same type that GSON should create
 * when deserializing that field. For example, consider these types:
 * <pre>   {@code
 *   abstract class Shape {

From source file jp.pay.model.ExternalAccountTypeAdapterFactory.java

public class ExternalAccountTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        if (!ExternalAccount.class.isAssignableFrom(type.getRawType())) {
            return null; // this class only serializes 'ExternalAccount' and its subtypes
        }

From source file jycraft.plugin.json.RuntimeTypeAdapterFactory.java

/**
 * Adapts values whose runtime type may differ from their declaration type. This
 * is necessary when a field's type is not the same type that GSON should create
 * when deserializing that field. For example, consider these types:
 * <pre>   {@code
 *   abstract class Shape {

From source file leafcutter.client.Serializer.java

final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
    private final Class<?> baseType;
    private final String typeFieldName;
    private final Map<String, Class<?>> labelToSubtype = new LinkedHashMap<String, Class<?>>();
    private final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<Class<?>, String>();