public static boolean isOptional ( final Type type ) { if ( OPTIONAL_CLASS == null ) { return false ; } if ( ! ( type instanceof ParameterizedType ) ) { // Either this is no Optional, or it's a raw optional which is useless for us anyway... return false ; } return OPTIONAL_CLASS . equals ( ( ( ParameterizedType ) type ) . getRawType ( ) ) ; }
Checks if given type is java . util . Optional with a generic type parameter .