Optional<T> is a way of replacing a nullable T reference with a non-null value. An Optional may either contain a non-null T reference (in which case we say the reference is “present”), or it may contain nothing (in which case we say the reference is “absent”). It is never said to “contain null.”
Make an Optional containing the given non-null value, or fail fast on null.
Return an absent Optional of some type.
Turn the given possibly-null reference into an Optional, treating non-null as present and null as absent.
Returns true if this Optional contains a non-null instance.
Returns the contained T instance, which must be present; otherwise, throws an IllegalStateException.
Returns the present value in this Optional, or if there is none, returns the specified default.
Returns the present value in this Optional, or if there is none, returns null. The inverse operation of fromNullable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15