@ SuppressWarnings ( "unchecked" ) public static < T > T getter ( Object target , Field field ) { boolean forceAccess = false ; try { if ( ! field . isAccessible ( ) ) { field . setAccessible ( true ) ; forceAccess = true ; } return ( T ) field . get ( target ) ; } catch ( IllegalAccessException ex ) { throw new ReflectionException ( ex ) ; } finally { if ( forceAccess ) { field . setAccessible ( false ) ; } } }
Get value of field on target object . If target is null it means that field is static and do not need any target instance .