List of usage examples for com.google.gson JsonObject get
public JsonElement get(String memberName)
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
@Override public Id.NamespacedId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); JsonObject id = jsonObj.getAsJsonObject("id"); String type = jsonObj.get("type").getAsString(); switch (type) { case "application": return deserializeApplicationId(id); case "program": return deserializeProgramId(id); case "flow": return deserializeFlowId(id); case "flowlet": return deserializeFlowletId(id); case "service": return deserializeServiceId(id); case "schedule": return deserializeSchedule(id); case "worker": return deserializeWorkerId(id); case "workflow": return deserializeWorkflowId(id); case "datasetinstance": return deserializeDatasetInstanceId(id); case "stream": return deserializeStreamId(id); case "view": return deserializeViewId(id); case "artifact": return deserializeArtifactId(id); default://ww w. ja v a2s . c om throw new UnsupportedOperationException(String.format( "Unsupported object of type %s found. Deserialization of only %s, %s, %s, %s, %s, %s, %s, " + "%s, %s, %s, %s, %s is supported.", type, Id.Application.class.getSimpleName(), Id.Program.class.getSimpleName(), Id.Flow.class.getSimpleName(), Id.Flow.Flowlet.class.getSimpleName(), Id.Service.class.getSimpleName(), Id.Schedule.class.getSimpleName(), Id.Worker.class.getSimpleName(), Id.Workflow.class.getSimpleName(), Id.DatasetInstance.class.getSimpleName(), Id.Stream.class.getSimpleName(), Id.Stream.View.class.getSimpleName(), Id.Artifact.class.getSimpleName())); } }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Application deserializeApplicationId(JsonObject id) { Id.Namespace namespace = deserializeNamespace(id); String applicationId = id.get("applicationId").getAsString(); return Id.Application.from(namespace, applicationId); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Artifact deserializeArtifactId(JsonObject id) { Id.Namespace namespace = deserializeNamespace(id); String artifactName = id.get("name").getAsString(); ArtifactVersion artifactVersion = new ArtifactVersion( id.get("version").getAsJsonObject().get("version").getAsString()); return Id.Artifact.from(namespace, artifactName, artifactVersion); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Namespace deserializeNamespace(JsonObject id) { String namespace = id.getAsJsonObject("namespace").get("id").getAsString(); return Id.Namespace.from(namespace); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Program deserializeProgramId(JsonObject id) { Id.Application app = deserializeApplicationId(id.getAsJsonObject("application")); ProgramType programType = ProgramType.valueOf(id.get("type").getAsString().toUpperCase()); String programId = id.get("id").getAsString(); return Id.Program.from(app, programType, programId); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Flow.Flowlet deserializeFlowletId(JsonObject id) { Id.Flow flow = deserializeFlowId(id.getAsJsonObject("flow")); String flowletId = id.get("id").getAsString(); return Id.Flow.Flowlet.from(flow, flowletId); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Schedule deserializeSchedule(JsonObject id) { Id.Application app = deserializeApplicationId(id.getAsJsonObject("application")); String scheduleId = id.get("id").getAsString(); return Id.Schedule.from(app, scheduleId); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.DatasetInstance deserializeDatasetInstanceId(JsonObject id) { Id.Namespace namespace = deserializeNamespace(id); String instanceId = id.get("instanceId").getAsString(); return Id.DatasetInstance.from(namespace, instanceId); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Stream deserializeStreamId(JsonObject id) { Id.Namespace namespace = deserializeNamespace(id); String streamName = id.get("streamName").getAsString(); return Id.Stream.from(namespace, streamName); }
From source file:co.cask.cdap.proto.codec.NamespacedIdCodec.java
License:Apache License
private Id.Stream.View deserializeViewId(JsonObject id) { Id.Stream streamId = deserializeStreamId(id.getAsJsonObject("stream")); String view = id.get("id").getAsString(); return Id.Stream.View.from(streamId, view); }