Example usage for com.google.gson JsonPrimitive JsonPrimitive

List of usage examples for com.google.gson JsonPrimitive JsonPrimitive

Introduction

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

Prototype

public JsonPrimitive(Character c) 

Source Link

Document

Create a primitive containing a character.

Usage

From source file:co.cask.cdap.internal.app.ApplicationSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(ApplicationSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("name", new JsonPrimitive(src.getName()));
    if (src.getConfiguration() != null) {
        jsonObj.add("configuration", new JsonPrimitive(src.getConfiguration()));
    }/*from ww  w.  j av  a  2 s .  c  o m*/
    jsonObj.add("artifactId", context.serialize(src.getArtifactId()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("streams", serializeMap(src.getStreams(), context, StreamSpecification.class));
    jsonObj.add("datasetModules", serializeMap(src.getDatasetModules(), context, String.class));
    jsonObj.add("datasetInstances", serializeMap(src.getDatasets(), context, DatasetCreationSpec.class));
    jsonObj.add("flows", serializeMap(src.getFlows(), context, FlowSpecification.class));
    jsonObj.add("mapReduces", serializeMap(src.getMapReduce(), context, MapReduceSpecification.class));
    jsonObj.add("sparks", serializeMap(src.getSpark(), context, SparkSpecification.class));
    jsonObj.add("workflows", serializeMap(src.getWorkflows(), context, WorkflowSpecification.class));
    jsonObj.add("services", serializeMap(src.getServices(), context, ServiceSpecification.class));
    jsonObj.add("schedules", serializeMap(src.getSchedules(), context, ScheduleSpecification.class));
    jsonObj.add("workers", serializeMap(src.getWorkers(), context, WorkerSpecification.class));
    jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class));

    return jsonObj;
}

From source file:co.cask.cdap.internal.app.FlowletSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(FlowletSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("className", new JsonPrimitive(src.getClassName()));
    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("failurePolicy", new JsonPrimitive(src.getFailurePolicy().name()));
    jsonObj.add("datasets", serializeSet(src.getDataSets(), context, String.class));
    jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));
    jsonObj.add("resources", context.serialize(src.getResources(), new TypeToken<ResourceSpecification>() {
    }.getType()));/*from   w w  w .ja  v a 2 s  .  c  o m*/

    return jsonObj;
}

From source file:co.cask.cdap.internal.app.FlowSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(FlowSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("className", new JsonPrimitive(src.getClassName()));
    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("flowlets", serializeMap(src.getFlowlets(), context, FlowletDefinition.class));
    jsonObj.add("connections", serializeList(src.getConnections(), context, FlowletConnection.class));

    return jsonObj;
}

From source file:co.cask.cdap.internal.app.MapReduceSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(MapReduceSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("className", new JsonPrimitive(src.getClassName()));
    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("mapperMemoryMB", new JsonPrimitive(src.getMapperMemoryMB()));
    jsonObj.add("reducerMemoryMB", new JsonPrimitive(src.getReducerMemoryMB()));
    if (src.getInputDataSet() != null) {
        jsonObj.add("inputDataSet", new JsonPrimitive(src.getInputDataSet()));
    }//  w ww. ja  v a 2  s.co  m
    if (src.getOutputDataSet() != null) {
        jsonObj.add("outputDataSet", new JsonPrimitive(src.getOutputDataSet()));
    }
    jsonObj.add("datasets", serializeSet(src.getDataSets(), context, String.class));
    jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));

    return jsonObj;
}

From source file:co.cask.cdap.internal.app.ProcedureSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(ProcedureSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("className", new JsonPrimitive(src.getClassName()));
    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("datasets", serializeSet(src.getDataSets(), context, String.class));
    jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));
    jsonObj.add("resources", context.serialize(src.getResources(), new TypeToken<ResourceSpecification>() {
    }.getType()));//from   w  w w .  j  a v a  2 s .  co  m
    jsonObj.addProperty("instances", src.getInstances());
    return jsonObj;
}

From source file:co.cask.cdap.internal.app.ResourceSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(ResourceSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("virtualCores", new JsonPrimitive(src.getVirtualCores()));
    jsonObj.add("memoryMB", new JsonPrimitive(src.getMemoryMB()));

    return jsonObj;
}

From source file:co.cask.cdap.internal.app.runtime.artifact.ArtifactRangeCodec.java

License:Apache License

@Override
public JsonElement serialize(ArtifactRange src, Type typeOfSrc, JsonSerializationContext context) {
    return new JsonPrimitive(src.toString());
}

From source file:co.cask.cdap.internal.app.ScheduleCodec.java

License:Apache License

@Override
public JsonElement serialize(Schedule src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("cronExpression", new JsonPrimitive(src.getCronEntry()));
    jsonObj.add("action", new JsonPrimitive(src.getAction().toString()));
    return jsonObj;
}

From source file:co.cask.cdap.internal.app.SparkSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(SparkSpecification src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("className", new JsonPrimitive(src.getClassName()));
    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("mainClassName", new JsonPrimitive(src.getMainClassName()));
    jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));

    return jsonObj;
}

From source file:co.cask.cdap.internal.app.WorkflowActionSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(WorkflowActionSpecification src, Type typeOfSrc,
        JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();

    jsonObj.add("className", new JsonPrimitive(src.getClassName()));
    jsonObj.add("name", new JsonPrimitive(src.getName()));
    jsonObj.add("description", new JsonPrimitive(src.getDescription()));
    jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));

    return jsonObj;
}