@ SafeVarargs public static < T > T getOptionalFieldValue ( Object object , String fieldName , Class < T > ... fieldType ) { Class < ? > clazz = null ; if ( object instanceof Class < ? > ) { clazz = ( Class < ? > ) object ; object = null ; } else { clazz = object . getClass ( ) ; } return getFieldValue ( object , clazz , fieldName , fieldType . length == 1 ? fieldType [ 0 ] : null , true ) ; }
Get optional field value from instance or class . Retrieve named field value from given instance or class ; if field is missing return null . Note that this method does not throw exceptions . Also if optional desired field type is present and named field is of different type returns null .