public static < T > T getFieldValue ( Object target , String fieldName ) { try { Field field = target . getClass ( ) . getDeclaredField ( fieldName ) ; field . setAccessible ( true ) ; @ SuppressWarnings ( "unchecked" ) T returnValue = ( T ) field . get ( target ) ; return returnValue ; } catch ( NoSuchFieldException e ) { throw handleException ( fieldName , e ) ; } catch ( IllegalAccessException e ) { throw handleException ( fieldName , e ) ; } }
Get target object field value