Example usage for com.google.gson JsonSerializationContext serialize

List of usage examples for com.google.gson JsonSerializationContext serialize

Introduction

In this page you can find the example usage for com.google.gson JsonSerializationContext serialize.

Prototype

public JsonElement serialize(Object src, Type typeOfSrc);

Source Link

Document

Invokes default serialization on the specified object passing the specific type information.

Usage

From source file:com.alignace.chargeio.mapper.gson.adapter.TokenReferenceAdapter.java

License:Apache License

public JsonElement serialize(TokenReferenceOption src, Type typeOfSrc, JsonSerializationContext context) {

    return context.serialize(src.getTokenId(), String.class);
}

From source file:com.asakusafw.lang.inspection.json.NodeAdapter.java

License:Apache License

@Override
public JsonElement serialize(InspectionNode src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject result = new JsonObject();
    result.add(KEY_ID, new JsonPrimitive(src.getId()));
    result.add(KEY_TITLE, new JsonPrimitive(src.getTitle()));
    result.add(KEY_INPUTS, context.serialize(extract(src.getInputs()), TYPE_PORTS));
    result.add(KEY_OUTPUTS, context.serialize(extract(src.getOutputs()), TYPE_PORTS));
    result.add(KEY_PROPERTIES, context.serialize(src.getProperties(), TYPE_PROPERTIES));
    result.add(KEY_ELEMENTS, context.serialize(extract(src.getElements()), TYPE_NODES));
    return result;
}

From source file:com.asakusafw.lang.inspection.json.PortAdapter.java

License:Apache License

@Override
public JsonElement serialize(InspectionNode.Port src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject result = new JsonObject();
    result.add(KEY_ID, new JsonPrimitive(src.getId()));
    result.add(KEY_PROPERTIES, context.serialize(src.getProperties(), TYPE_PROPERTIES));
    result.add(KEY_OPPOSITES, context.serialize(src.getOpposites(), TYPE_REFERENCES));
    return result;
}

From source file:com.baidu.rigel.biplatform.ac.util.serialize.CubeSerialize.java

License:Open Source License

@Override
public JsonElement serialize(Cube src, Type typeOfSrc, JsonSerializationContext context) {
    return context.serialize(src, MiniCube.class);
}

From source file:com.baidu.rigel.biplatform.ac.util.serialize.DataSourceInfoSerialize.java

License:Open Source License

@Override
public JsonElement serialize(DataSourceInfo src, Type typeOfSrc, JsonSerializationContext context) {
    if (src.getDataSourceType().equals(DataSourceType.SQL)) {
        return context.serialize(src, SqlDataSourceInfo.class);
    }//from  w  ww.j  av a2 s  .  c o m
    return null;
}

From source file:com.baidu.rigel.biplatform.ac.util.serialize.DimensionSerialize.java

License:Open Source License

@Override
public JsonElement serialize(Dimension src, Type typeOfSrc, JsonSerializationContext context) {

    if (src.getType().equals(DimensionType.TIME_DIMENSION)) {
        return context.serialize(src, TimeDimension.class);
    } else {//from  w ww . ja  v  a 2s.c  o m
        return context.serialize(src, StandardDimension.class);
    }
}

From source file:com.baidu.rigel.biplatform.ac.util.serialize.LevelSerialize.java

License:Open Source License

@Override
public JsonElement serialize(Level src, Type typeOfSrc, JsonSerializationContext context) {
    if (src.getType().equals(LevelType.CALL_BACK)) {
        return context.serialize(src, CallbackLevel.class);
    } else if (src.getType().equals(LevelType.USER_CUSTOM)) {
        return context.serialize(src, UserCustomLevel.class);
    } else {//from w  ww  .j  a v a 2s  .  c  om
        return context.serialize(src, MiniCubeLevel.class);
    }
}

From source file:com.baidu.rigel.biplatform.ac.util.serialize.MeasureSerialize.java

License:Open Source License

@Override
public JsonElement serialize(Measure src, Type typeOfSrc, JsonSerializationContext context) {
    if (src.getAggregator().equals(Aggregator.CALCULATED)) {
        if (src.getType().equals(MeasureType.CALLBACK)) {
            return context.serialize(src, CallbackMeasure.class);
        }//w ww  .  j  ava  2 s .  co  m
        return context.serialize(src, ExtendMinicubeMeasure.class);
    }
    return context.serialize(src, MiniCubeMeasure.class);
}

From source file:com.baidu.rigel.biplatform.ac.util.serialize.MetaConditionSerialize.java

License:Open Source License

@Override
public JsonElement serialize(MetaCondition src, Type typeOfSrc, JsonSerializationContext context) {
    if (src.getMetaType().equals(MetaType.Dimension)) {
        return context.serialize(src, DimensionCondition.class);
    } else {/*from   w  ww .  ja  va 2  s.  c o m*/
        return context.serialize(src, MeasureCondition.class);
    }
}

From source file:com.berniesanders.fieldthebern.parsing.CanvassDataSerializer.java

License:Apache License

@Override
public JsonElement serialize(CanvassData src, Type typeOfSrc, JsonSerializationContext context) {

    if (ApiAddress.TYPE.equals(src.type())) {
        return context.serialize(src, ApiAddress.class);
    } else if (Person.TYPE.equals(src.type())) {
        return context.serialize(src, Person.class);
    } else if (UserData.TYPE.equals(src.type())) {
        return context.serialize(src, UserData.class);
    } else {/*from   w  w w  .  j  a v  a  2s. c  om*/
        return null;
    }
}