private static Method getReadMethod ( Object object , String propertyName ) { String getMethodName = "get" + propertyName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + propertyName . substring ( 1 ) ; String isMethodName = "is" + propertyName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + propertyName . substring ( 1 ) ; Method [ ] methods = getMethods ( object ) ; for ( Method method : methods ) { if ( ( method . getName ( ) . equals ( getMethodName ) || method . getName ( ) . equals ( isMethodName ) ) && ( method . getParameterTypes ( ) . length == 0 ) ) { return method ; } } return null ; }
Tries to find the Java method to read a given propertyName for the given object .