public < T > Optional < T > as ( Class < T > type ) { return inner . filter ( d -> d . is ( type ) ) . map ( d -> d . as ( type ) ) ; }
Returns inner value as optional of input type if the inner value is absent or not an instance of the input type an empty optional is returned