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.WorkflowSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(WorkflowSpecification 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("actions", serializeList(src.getActions(), context, WorkflowActionSpecification.class));
    jsonObj.add("mapReduces", serializeMap(src.getMapReduce(), context, MapReduceSpecification.class));
    jsonObj.add("schedules", serializeList(src.getSchedules(), context, Schedule.class));

    return jsonObj;
}

From source file:co.cask.cdap.internal.filesystem.LocationCodec.java

License:Apache License

@Override
public JsonElement serialize(Location src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();
    jsonObj.add("uri", new JsonPrimitive(src.toURI().toASCIIString()));
    return jsonObj;
}

From source file:co.cask.cdap.proto.codec.CustomActionSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(CustomActionSpecification 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));

    return jsonObj;
}

From source file:co.cask.cdap.proto.codec.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(), Resources.class));

    return jsonObj;
}

From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java

License:Apache License

@Override
public JsonElement serialize(Id.NamespacedId src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject jsonObj = new JsonObject();
    jsonObj.add("type", new JsonPrimitive(src.getIdType()));
    jsonObj.add("id", context.serialize(src));

    return jsonObj;
}

From source file:co.cask.cdap.proto.codec.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));

    if (src.getDriverResources() != null) {
        jsonObj.add("driverResources", context.serialize(src.getDriverResources()));
    }/*from  ww  w.  j  av a 2  s.c  o  m*/
    if (src.getExecutorResources() != null) {
        jsonObj.add("executorResources", context.serialize(src.getExecutorResources()));
    }

    return jsonObj;
}

From source file:co.cask.cdap.proto.codec.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("datasets", serializeSet(src.getDatasets(), context, String.class));
    jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));

    return jsonObj;
}

From source file:co.cask.cdap.proto.codec.WorkflowSpecificationCodec.java

License:Apache License

@Override
public JsonElement serialize(WorkflowSpecification 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));
    jsonObj.add("nodes", serializeList(src.getNodes(), context, WorkflowNode.class));
    jsonObj.add("localDatasetSpecs",
            serializeMap(src.getLocalDatasetSpecs(), context, DatasetCreationSpec.class));
    return jsonObj;
}

From source file:co.cask.tigon.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("properties", serializeMap(src.getProperties(), context, String.class));
    jsonObj.add("resources", context.serialize(src.getResources(), new TypeToken<ResourceSpecification>() {
    }.getType()));//  www. ja  v a 2  s .  c  o m
    jsonObj.add("maxInstances", new JsonPrimitive(src.getMaxInstances()));

    return jsonObj;
}

From source file:co.forsaken.projectindigo.utils.mojangtokens.DateTypeAdapter.java

License:Open Source License

@Override
public JsonElement serialize(Date value, Type type, JsonSerializationContext context) {
    synchronized (enUsFormat) {
        String ret = this.iso8601Format.format(value);
        return new JsonPrimitive(ret.substring(0, 22) + ":" + ret.substring(22));
    }//from  w w w . ja  v a  2  s.c om
}