List of usage examples for com.google.gson JsonDeserializationContext deserialize
public <T> T deserialize(JsonElement json, Type typeOfT) throws JsonParseException;
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());/* w w w. j av a 2 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 ww w . j ava2 s. 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); }
From source file:com.continuuity.loom.codec.json.current.HardwareTypeCodec.java
License:Apache License
@Override public HardwareType 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<String, Map<String, String>> providerMap = context.deserialize(jsonObj.get("providermap"), new TypeToken<Map<String, Map<String, String>>>() { }.getType());// w ww .java 2s. co m return new HardwareType(name, description, providerMap); }
From source file:com.continuuity.loom.codec.json.current.ImageTypeCodec.java
License:Apache License
@Override public ImageType 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<String, Map<String, String>> providerMap = context.deserialize(jsonObj.get("providermap"), new TypeToken<Map<String, Map<String, String>>>() { }.getType());/*from w w w .j a va 2 s . c o m*/ return new ImageType(name, description, providerMap); }
From source file:com.continuuity.loom.codec.json.current.LayoutConstraintCodec.java
License:Apache License
@Override public LayoutConstraint deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Set<Set<String>> servicesThatMustCoexist = context.deserialize(jsonObj.get("mustcoexist"), new TypeToken<Set<Set<String>>>() { }.getType());/*from ww w .j a v a 2s.com*/ Set<Set<String>> servicesThatMustNotCoexist = context.deserialize(jsonObj.get("cantcoexist"), new TypeToken<Set<Set<String>>>() { }.getType()); return new LayoutConstraint(servicesThatMustCoexist, servicesThatMustNotCoexist); }
From source file:com.continuuity.loom.codec.json.current.LeaseDurationCodec.java
License:Apache License
@Override public LeaseDuration deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Long initial = context.deserialize(jsonObj.get("initial"), Long.class); Long max = context.deserialize(jsonObj.get("max"), Long.class); Long step = context.deserialize(jsonObj.get("step"), Long.class); return new LeaseDuration(initial, max, step); }
From source file:com.continuuity.loom.codec.json.current.ParametersSpecificationCodec.java
License:Apache License
@Override public ParametersSpecification deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Map<String, FieldSchema> fields = context.deserialize(jsonObj.get("fields"), new TypeToken<Map<String, FieldSchema>>() { }.getType());// w w w. j a v a 2 s .c o m Set<Set<String>> required = context.deserialize(jsonObj.get("required"), new TypeToken<Set<Set<String>>>() { }.getType()); return new ParametersSpecification(fields, required); }
From source file:com.continuuity.loom.codec.json.current.PluginResourceMetaCodec.java
License:Apache License
@Override public ResourceMeta deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); String name = context.deserialize(jsonObj.get("name"), String.class); Integer version = context.deserialize(jsonObj.get("version"), Integer.class); ResourceStatus status = context.deserialize(jsonObj.get("status"), ResourceStatus.class); return new ResourceMeta(name, version, status); }
From source file:com.continuuity.loom.codec.json.current.ProviderCodec.java
License:Apache License
@Override public Provider 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 providerType = context.deserialize(jsonObj.get("providertype"), String.class); Map<String, String> provisionerFields = context.deserialize(jsonObj.get("provisioner"), new TypeToken<Map<String, String>>() { }.getType());//from w w w . j ava2s. c o m return new Provider(name, description, providerType, provisionerFields); }