private Optional < RegistryEntry > getRegistryEntry ( Object response ) { if ( response != null ) { Class responseClass = response . getClass ( ) ; boolean resourceList = ResourceList . class . isAssignableFrom ( responseClass ) ; if ( resourceList ) { ResourceList responseList = ( ResourceList ) response ; if ( responseList . isEmpty ( ) ) { return Optional . empty ( ) ; } // get common super class of all list element => resource class Class elementType = responseList . get ( 0 ) . getClass ( ) ; for ( int i = 0 ; i < responseList . size ( ) ; i ++ ) { Class otherType = responseList . get ( i ) . getClass ( ) ; while ( ! elementType . isAssignableFrom ( otherType ) ) { elementType = elementType . getSuperclass ( ) ; } } responseClass = elementType ; } ResourceRegistry resourceRegistry = feature . getBoot ( ) . getResourceRegistry ( ) ; if ( resourceRegistry . hasEntry ( responseClass ) ) { return Optional . of ( resourceRegistry . getEntry ( responseClass ) ) ; } } return Optional . empty ( ) ; }
Determines whether the given response entity is either a Crnk resource or a list of resource ;