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 ) ; } } // Handle meta 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 ) ; } } // Handle links if ( source . has ( LINKS ) ) { Field linkField = configuration . getLinksField ( type ) ; if ( linkField != null ) { linkField . set ( result , new Links ( mapLinks ( source . get ( LINKS ) ) ) ) ; } } if ( result != null ) { // Add parsed object to cache resourceCache . cache ( identifier , result ) ; // Set object id setIdValue ( result , source . get ( ID ) ) ; if ( handleRelationships ) { // Handle relationships handleRelationships ( source , result ) ; } } } return result ; }
Converts provided input into a target object . After conversion completes any relationships defined are resolved .