/** * Parses out included resources excluding relationships. * @param parent root node * @return map of identifier/resource pairs * @throws IOException * @throws IllegalAccessException * @throws InstantiationException */ private Map<String, Object> getIncludedResources(JsonNode parent) throws IOException, IllegalAccessException, InstantiationException { Map<String, Object> result = new HashMap<>(); if (parent.has(INCLUDED)) { for (JsonNode jsonNode : parent.get(INCLUDED)) { String type = jsonNode.get(TYPE).asText(); Class<?> clazz = configuration.getTypeClass(type); if (clazz != null) { Object object = readObject(jsonNode, clazz, false); if (object != null) { result.put(createIdentifier(jsonNode), object); } } else if (!deserializationFeatures.contains(DeserializationFeature.ALLOW_UNKNOWN_INCLUSIONS)) { throw new IllegalArgumentException("Included section contains unknown resource type: " + type); } } } return result; }
/** * Parses out included resources excluding relationships. * @param parent root node * @return map of identifier/resource pairs * @throws IOException * @throws IllegalAccessException * @throws InstantiationException */ private Map<String, Object> getIncludedResources(JsonNode parent) throws IOException, IllegalAccessException, InstantiationException { Map<String, Object> result = new HashMap<>(); if (parent.has(INCLUDED)) { for (JsonNode jsonNode : parent.get(INCLUDED)) { String type = jsonNode.get(TYPE).asText(); Class<?> clazz = configuration.getTypeClass(type); if (clazz != null) { Object object = readObject(jsonNode, clazz, false); if (object != null) { result.put(createIdentifier(jsonNode), object); } } else if (!deserializationFeatures.contains(DeserializationFeature.ALLOW_UNKNOWN_INCLUSIONS)) { throw new IllegalArgumentException("Included section contains unknown resource type: " + type); } } } return result; }
Object resourceObject = includedResources.get(createIdentifier(node)); if (resourceObject != null){ handleRelationships(node, resourceObject);
Object resourceObject = includedResources.get(createIdentifier(node)); if (resourceObject != null){ handleRelationships(node, resourceObject);
String identifier = createIdentifier(source);
String identifier = createIdentifier(source);
boolean cached = false; if (dataNode != null && dataNode.isObject()) { String identifier = createIdentifier(dataNode); cached = identifier != null && resourceCache.contains(identifier);
boolean cached = false; if (dataNode != null && dataNode.isObject()) { String identifier = createIdentifier(dataNode); cached = identifier != null && resourceCache.contains(identifier);
/** * Creates relationship object by consuming provided 'data' node. * @param relationshipDataNode relationship data node * @param type object type * @return created object or <code>null</code> in case data node is not valid * @throws IOException * @throws IllegalAccessException * @throws InstantiationException */ private Object parseRelationship(JsonNode relationshipDataNode, Class<?> type) throws IOException, IllegalAccessException, InstantiationException { if (ValidationUtils.isRelationshipParsable(relationshipDataNode)) { String identifier = createIdentifier(relationshipDataNode); if (resourceCache.contains(identifier)) { return resourceCache.get(identifier); } else { // Never cache relationship objects resourceCache.lock(); try { return readObject(relationshipDataNode, type, true); } finally { resourceCache.unlock(); } } } return null; }
/** * Creates relationship object by consuming provided 'data' node. * @param relationshipDataNode relationship data node * @param type object type * @return created object or <code>null</code> in case data node is not valid * @throws IOException * @throws IllegalAccessException * @throws InstantiationException */ private Object parseRelationship(JsonNode relationshipDataNode, Class<?> type) throws IOException, IllegalAccessException, InstantiationException { if (ValidationUtils.isRelationshipParsable(relationshipDataNode)) { String identifier = createIdentifier(relationshipDataNode); if (resourceCache.contains(identifier)) { return resourceCache.get(identifier); } else { // Never cache relationship objects resourceCache.lock(); try { return readObject(relationshipDataNode, type, true); } finally { resourceCache.unlock(); } } } return null; }