private MethodHandle findIdReadMethod ( ) { try { Method readMethod = clazz . getMethod ( READ_METHOD_NAME ) ; Class < ? > dataClass = readMethod . getReturnType ( ) ; DataType dataType = IdentifierMetadata . DataType . forClass ( dataClass ) ; if ( dataType == null ) { String pattern = "Method %s in class %s must have a return type of long, Long or String" ; String error = String . format ( pattern , READ_METHOD_NAME , clazz . getName ( ) ) ; throw new EntityManagerException ( error ) ; } return MethodHandles . lookup ( ) . unreflect ( readMethod ) ; } catch ( NoSuchMethodException | SecurityException | IllegalAccessException exp ) { String error = String . format ( "Class %s must have a public %s method" , clazz . getName ( ) , READ_METHOD_NAME ) ; throw new EntityManagerException ( error , exp ) ; } }
Creates and returns the MethodHandle for reading the underlying ID .