private <T>T readObject(JsonNode source,Class<T> clazz,boolean handleRelationships) throws IOException, IllegalAccessException, InstantiationException {
  String identifier=createIdentifier(source);
  T result=(T)resourceCache.get(identifier);
  if (result == null) {
    Class<?> type=getActualType(source,clazz);
    if (source.has(ATTRIBUTES)) {
      result=(T)objectMapper.treeToValue(source.get(ATTRIBUTES),type);
    }
 else {
      if (type.isInterface()) {
        result=null;
      }
 else {
        result=(T)objectMapper.treeToValue(objectMapper.createObjectNode(),type);
      }
    }
    if (source.has(META)) {
      Field field=configuration.getMetaField(type);
      if (field != null) {
        Class<?> metaType=configuration.getMetaType(type);
        Object metaObject=objectMapper.treeToValue(source.get(META),metaType);
        field.set(result,metaObject);
      }
    }
    if (source.has(LINKS)) {
      Field linkField=configuration.getLinksField(type);
      if (linkField != null) {
        linkField.set(result,new Links(mapLinks(source.get(LINKS))));
      }
    }
    if (result != null) {
      resourceCache.cache(identifier,result);
      setIdValue(result,source.get(ID));
      if (handleRelationships) {
        handleRelationships(source,result);
      }
    }
  }
  return result;
}

private < T > T readObject ( JsonNode source , Class < T > clazz , boolean handleRelationships ) throws IOException , IllegalAccessException , InstantiationException { String identifier = createIdentifier ( source ) ; T result = ( T ) resourceCache . get ( identifier ) ; if ( result == null ) { Class < ? > type = getActualType ( source , clazz ) ; if ( source . has ( ATTRIBUTES ) ) { result = ( T ) objectMapper . treeToValue ( source . get ( ATTRIBUTES ) , type ) ; } else { if ( type . isInterface ( ) ) { result = null ; } else { result = ( T ) objectMapper . treeToValue ( objectMapper . createObjectNode ( ) , type ) ; } } if ( source . has ( META ) ) { Field field = configuration . getMetaField ( type ) ; if ( field != null ) { Class < ? > metaType = configuration . getMetaType ( type ) ; Object metaObject = objectMapper . treeToValue ( source . get ( META ) , metaType ) ; field . set ( result , metaObject ) ; } } if ( source . has ( LINKS ) ) { Field linkField = configuration . getLinksField ( type ) ; if ( linkField != null ) { linkField . set ( result , new Links ( mapLinks ( source . get ( LINKS ) ) ) ) ; } } if ( result != null ) { resourceCache . cache ( identifier , result ) ; setIdValue ( result , source . get ( ID ) ) ; if ( handleRelationships ) { handleRelationships ( source , result ) ; } } } return result ; }
converts provided input into a target object . after conversion completes any relationships defined are resolved .
