reader.beginArray();
Codex<EntityMetadata> metaCodex = typeContext.getCodex(EntityMetadata.class);
while (!JsonToken.END_ARRAY.equals(reader.peek())) {
JsonObject metaElement = jsonParser.parse(reader).getAsJsonObject();
PackReader packReader = packReaders.get();
packReader.setPayload(metaElement);
EntityMetadata meta = new EntityMetadata();
meta.setUuid(UUID.fromString(metaElement.get("uuid").getAsString()));
meta = visitors.getWalkers().walkSingleton(metaCodex).accept(packReader, meta);
toReturn.addMetadata(meta);
}
reader.endArray();
} else if ("value".equals(name)) {
// Just stash the value element in case it occurs first
value = jsonParser.parse(reader);
} else if ("warnings".equals(name)) {
// "warnings" : { "path" : "problem", "path2" : "problem2" }
reader.beginObject();
while (JsonToken.NAME.equals(reader.peek())) {
String path = reader.nextName();
if (JsonToken.STRING.equals(reader.peek()) || JsonToken.NUMBER.equals(reader.peek())) {
toReturn.addWarning(path, reader.nextString());
} else {
reader.skipValue();
}
}
reader.endObject();
} else if (JsonToken.STRING.equals(reader.peek()) || JsonToken.NUMBER.equals(reader.peek())) {
// Save off any other simple properties
toReturn.putExtraData(name, reader.nextString());
} else {
// Ignore random other entries
reader.skipValue();
}
}
reader.endObject();
reader.close();
PackReader packReader = packReaders.get();
for (Map.Entry<HasUuid, JsonObject> entry : entityData.entrySet()) {
HasUuid entity = entry.getKey();
EntityCodex<HasUuid> codex = (EntityCodex<HasUuid>) typeContext
.getCodex(entity.getClass());
packReader.setPayload(entry.getValue());
visitors.getWalkers().walkImmutable(codex).accept(packReader, entity);
}
@SuppressWarnings("unchecked")
Codex<T> returnCodex = (Codex<T>) typeContext.getCodex(toReturn.getType());