public final static Method getAttributeGetter ( Class cls , String attr ) throws NoSuchMethodException { StringBuffer buf = new StringBuffer ( attr . length ( ) + 3 ) ; buf . append ( "get" ) ; if ( Character . isLowerCase ( attr . charAt ( 0 ) ) ) { buf . append ( Character . toUpperCase ( attr . charAt ( 0 ) ) ) . append ( attr . substring ( 1 ) ) ; } else { buf . append ( attr ) ; } try { return cls . getMethod ( buf . toString ( ) , ( Class [ ] ) null ) ; } catch ( NoSuchMethodException e ) { buf . replace ( 0 , 3 , "is" ) ; return cls . getMethod ( buf . toString ( ) , ( Class [ ] ) null ) ; } }
Returns attribute s getter method . If the method not found then NoSuchMethodException will be thrown .