/** * Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional. * * @param value the possibly-null value to describe * @return an Optional with a present value if the specified value is non-null, otherwise an empty Optional */ public static <T> Optional<T> ofNullable(T value){ if(value == null){ return empty(); } return new Optional<>(value); }