}
@Override
public Catalog deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
final Catalog result = CatalogFactory.eINSTANCE.createCatalog();
JsonObject jsonObj = json.getAsJsonObject();
// Check the document type
String documentType = getString(jsonObj, "document_type");
if(!"Catalog".equals(documentType))
throw new IllegalArgumentException("JSON document must be of 'Catalog' type");
result.setMetadata(getMetadata(jsonObj, "metadata", context));
// all the data is under a 'data' key
JsonElement data = jsonObj.get("data");
if(data == null)
return result;
if(!(data instanceof JsonObject))
throw new IllegalStateException("Document 'data' is not a single object");
// continue serialization under data
jsonObj = data.getAsJsonObject();
result.setName(getString(jsonObj, "name"));
result.setVersion(getString(jsonObj, "version"));
json = jsonObj.get("tags");
if(json != null)
deserializeInto(json, result.getTags(), String.class, context);
json = jsonObj.get("classes");
if(json != null)
deserializeInto(json, result.getClasses(), String.class, context);
json = jsonObj.get("resources");
if(json != null)
deserializeInto(json, result.getResources(), CatalogResourceImpl.class, context);
json = jsonObj.get("edges");
if(json != null)
deserializeInto(json, result.getEdges(), CatalogEdgeImpl.class, context);
return result;
}