List of usage examples for com.google.gson JsonElement getAsJsonObject
public JsonObject getAsJsonObject()
From source file:com.continuuity.loom.codec.json.current.AutomatorTypeCodec.java
License:Apache License
@Override public AutomatorType deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String name = context.deserialize(jsonObj.get("name"), String.class); String description = context.deserialize(jsonObj.get("description"), String.class); Map<ParameterType, ParametersSpecification> parameters = context.deserialize(jsonObj.get("parameters"), new TypeToken<Map<ParameterType, ParametersSpecification>>() { }.getType());/*from w w w . j a v a2s. c om*/ Map<String, ResourceTypeSpecification> resourceTypes = context.deserialize(jsonObj.get("resourceTypes"), new TypeToken<Map<String, ResourceTypeSpecification>>() { }.getType()); return new AutomatorType(name, description, parameters, resourceTypes); }
From source file:com.continuuity.loom.codec.json.current.ClusterCodec.java
License:Apache License
@Override public Cluster deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String id = context.deserialize(jsonObj.get("id"), String.class); String name = context.deserialize(jsonObj.get("name"), String.class); String description = context.deserialize(jsonObj.get("description"), String.class); long createTime = jsonObj.get("createTime").getAsLong(); Long expireTime = context.deserialize(jsonObj.get("expireTime"), Long.class); Provider provider = context.deserialize(jsonObj.get("provider"), Provider.class); ClusterTemplate template = context.deserialize(jsonObj.get("clusterTemplate"), ClusterTemplate.class); Set<String> nodes = context.deserialize(jsonObj.get("nodes"), new TypeToken<Set<String>>() { }.getType());//from w w w .j a va 2 s .com Set<String> services = context.deserialize(jsonObj.get("services"), new TypeToken<Set<String>>() { }.getType()); String latestJobId = context.deserialize(jsonObj.get("latestJobId"), String.class); Account account = context.deserialize(jsonObj.get("account"), Account.class); Cluster.Status status = context.deserialize(jsonObj.get("status"), Cluster.Status.class); JsonObject config = context.deserialize(jsonObj.get("config"), JsonObject.class); return new Cluster(id, account, name, createTime, expireTime == null ? 0 : expireTime, description, provider, template, nodes, services, config, status, latestJobId); }
From source file:com.continuuity.loom.codec.json.current.ClusterConfigureRequestCodec.java
License:Apache License
@Override public ClusterConfigureRequest deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Boolean restart = context.deserialize(jsonObj.get("restart"), Boolean.class); JsonObject config = context.deserialize(jsonObj.get("config"), JsonObject.class); return new ClusterConfigureRequest(config, restart); }
From source file:com.continuuity.loom.codec.json.current.ClusterCreateRequestCodec.java
License:Apache License
@Override public ClusterCreateRequest deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String name = context.deserialize(jsonObj.get("name"), String.class); String description = context.deserialize(jsonObj.get("description"), String.class); String clusterTemplate = context.deserialize(jsonObj.get("clusterTemplate"), String.class); Integer numMachines = context.deserialize(jsonObj.get("numMachines"), Integer.class); String provider = context.deserialize(jsonObj.get("provider"), String.class); Map<String, String> providerFields = context.deserialize(jsonObj.get("providerFields"), new TypeToken<Map<String, String>>() { }.getType());// w w w . j a v a 2 s. c om Set<String> services = context.deserialize(jsonObj.get("services"), new TypeToken<Set<String>>() { }.getType()); String hardwaretype = context.deserialize(jsonObj.get("hardwaretype"), String.class); String imagetype = context.deserialize(jsonObj.get("imagetype"), String.class); Long initialLeaseDuration = context.deserialize(jsonObj.get("initialLeaseDuration"), Long.class); String dnsSuffix = context.deserialize(jsonObj.get("dnsSuffix"), String.class); JsonObject config = context.deserialize(jsonObj.get("config"), JsonObject.class); return new ClusterCreateRequest(name, description, clusterTemplate, numMachines, provider, providerFields, services, hardwaretype, imagetype, initialLeaseDuration, dnsSuffix, config); }
From source file:com.continuuity.loom.codec.json.current.ClusterDefaultsCodec.java
License:Apache License
@Override public ClusterDefaults deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Set<String> services = context.deserialize(jsonObj.get("services"), new TypeToken<Set<String>>() { }.getType());//w ww.j av a2s. c o m String provider = context.deserialize(jsonObj.get("provider"), String.class); String hardwaretype = context.deserialize(jsonObj.get("hardwaretype"), String.class); String imagetype = context.deserialize(jsonObj.get("imagetype"), String.class); String dnsSuffix = context.deserialize(jsonObj.get("dnsSuffix"), String.class); JsonObject config = context.deserialize(jsonObj.get("config"), JsonObject.class); return new ClusterDefaults(services, provider, hardwaretype, imagetype, dnsSuffix, config); }
From source file:com.continuuity.loom.codec.json.current.ClusterTemplateCodec.java
License:Apache License
@Override public ClusterTemplate deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String name = context.deserialize(jsonObj.get("name"), String.class); String description = context.deserialize(jsonObj.get("description"), String.class); ClusterDefaults defaults = context.deserialize(jsonObj.get("defaults"), ClusterDefaults.class); Compatibilities compatibilites = context.deserialize(jsonObj.get("compatibility"), Compatibilities.class); Constraints constraints = context.deserialize(jsonObj.get("constraints"), Constraints.class); Administration administration = context.deserialize(jsonObj.get("administration"), Administration.class); return new ClusterTemplate(name, description, defaults, compatibilites, constraints, administration); }
From source file:com.continuuity.loom.codec.json.current.CompatibilitiesCodec.java
License:Apache License
@Override public Compatibilities deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Set<String> hardwaretypes = context.deserialize(jsonObj.get("hardwaretypes"), new TypeToken<Set<String>>() { }.getType());/*from w ww.j a v a 2 s .c o m*/ Set<String> imagetypes = context.deserialize(jsonObj.get("imagetypes"), new TypeToken<Set<String>>() { }.getType()); Set<String> services = context.deserialize(jsonObj.get("services"), new TypeToken<Set<String>>() { }.getType()); return new Compatibilities(hardwaretypes, imagetypes, services); }
From source file:com.continuuity.loom.codec.json.current.ConstraintsCodec.java
License:Apache License
@Override public Constraints deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); LayoutConstraint layoutConstraint = context.deserialize(jsonObj.get("layout"), LayoutConstraint.class); Map<String, ServiceConstraint> serviceConstraints = context.deserialize(jsonObj.get("services"), new TypeToken<Map<String, ServiceConstraint>>() { }.getType());/* ww w . j a v a2 s .c o m*/ return new Constraints(serviceConstraints, layoutConstraint); }
From source file:com.continuuity.loom.codec.json.current.FieldSchemaCodec.java
License:Apache License
@Override public FieldSchema deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String label = context.deserialize(jsonObj.get("label"), String.class); String fieldType = context.deserialize(jsonObj.get("type"), String.class); String tip = context.deserialize(jsonObj.get("tip"), String.class); String defaultValue = context.deserialize(jsonObj.get("default"), String.class); Boolean override = context.deserialize(jsonObj.get("override"), Boolean.class); Set<String> options = context.deserialize(jsonObj.get("options"), new TypeToken<Set<String>>() { }.getType());/*from w w w . j a v a 2s . c om*/ return new FieldSchema(label, fieldType, tip, options, defaultValue, override); }
From source file:com.continuuity.loom.codec.json.current.FinishTaskRequestCodec.java
License:Apache License
@Override public FinishTaskRequest deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String workerId = context.deserialize(jsonObj.get("workerId"), String.class); String provisionerId = context.deserialize(jsonObj.get("provisionerId"), String.class); String tenantId = context.deserialize(jsonObj.get("tenantId"), String.class); String taskId = context.deserialize(jsonObj.get("taskId"), String.class); String stdout = context.deserialize(jsonObj.get("stdout"), String.class); String stderr = context.deserialize(jsonObj.get("stderr"), String.class); Integer status = context.deserialize(jsonObj.get("status"), Integer.class); JsonObject result = context.deserialize(jsonObj.get("result"), JsonObject.class); return new FinishTaskRequest(workerId, provisionerId, tenantId, taskId, stdout, stderr, status, result); }