public static Object unwrap ( final Class < ? > type , final Object object ) throws Exception { if ( object == null ) { return null ; } if ( type == null ) { return object ; } if ( Callable . class . equals ( type ) ) { assert ( object instanceof Callable ) ; return ( ( Callable < ? > ) object ) . call ( ) ; } if ( "java.util.function.Supplier" . equals ( type . getName ( ) ) ) { return findMethodByName ( type , "get" ) . invoke ( object , ( Object [ ] ) null ) ; } return object ; }
Unwrap a given object until we assume it is a value . Supports Callable and Supplier so far .