T - the instance typepublic abstract class Nillable<T> extends Object
isNil(), isAbsent() and isPresent() are mutually exclusive true.| Modifier and Type | Method and Description |
|---|---|
static <T> Nillable<T> |
absent()
Creates a
Nillable for a absent instance. |
abstract T |
get()
Returns the object if present.
|
abstract Optional<String> |
getNilReason()
Returns the optional reason for this object being nil.
|
boolean |
hasReason()
Checks if this
Nillable is nil and has a reason. |
static <T> Nillable<T> |
inapplicable()
Creates a new
Nillable, that is nil because it is inapplicable. |
abstract boolean |
isAbsent()
Checks if this
Nillable is null. |
abstract boolean |
isNil()
Checks if this
Nillable is nil. |
boolean |
isNull()
Checks if this
Nillable is null. |
abstract boolean |
isPresent()
Checks if this
Nillable is present. |
boolean |
isPresentOrNil()
Checks if this this instance is not absent.
|
abstract <X> Nillable<X> |
map(Function<? super T,X> fun)
Transforms this
Nillable to the target type. |
static <T> Nillable<T> |
missing()
Creates a new
Nillable, that is nil because it is missing. |
static <T> Nillable<T> |
nil()
Creates a new
Nillable that is nil. |
static <T> Nillable<T> |
nil(String reason)
Creates a new
Nillable that is nil because of optionally supplied reason. |
static <T> Nillable<T> |
of(T obj)
Creates a new
Nillable that is either present (if obj is not null), or absent. |
static <T> Nillable<T> |
of(T obj,
String reason)
Creates a new
Nillable that is either present (if obj is not null), nil (if
reason is not null) or absent. |
static <T> Nillable<T> |
present(T t)
Creates a new
Nillable from a present instance. |
static <T> Nillable<T> |
template()
Creates a new
Nillable, that is nil because it is a template value. |
static <T> Nillable<T> |
unknown()
Creates a new
Nillable, that is nil because it is unknown. |
static <T> Nillable<T> |
withheld()
Creates a new
Nillable, that is nil because it is withheld. |
public abstract boolean isNil()
Nillable is nil.nilisPresent(),
isAbsent()public abstract boolean isPresent()
Nillable is present.isNil(),
isAbsent()public abstract boolean isAbsent()
Nillable is null.nullisNil(),
isPresent()public abstract <X> Nillable<X> map(Function<? super T,X> fun)
Nillable to the target type.X - the target typefun - the transformation functionNillablepublic boolean isNull()
Nillable is null.nullisAbsent()public boolean isPresentOrNil()
public abstract T get()
UnsupportedOperationException - if this instance is not presentisPresent()public boolean hasReason()
Nillable is nil and has a reason.public abstract Optional<String> getNilReason()
UnsupportedOperationException - if this instance is not nilisNil()public static <T> Nillable<T> present(T t)
Nillable from a present instance.T - the typet - the objectNillableNullPointerException - if t is nullpublic static <T> Nillable<T> absent()
Nillable for a absent instance.T - the typeNillablepublic static <T> Nillable<T> nil(String reason)
Nillable that is nil because of optionally supplied reason.T - the typereason - the reason (may be null)Nillablepublic static <T> Nillable<T> nil()
Nillable that is nil.T - the typeNillablepublic static <T> Nillable<T> inapplicable()
Nillable, that is nil because it is inapplicable.T - the typeNillablepublic static <T> Nillable<T> missing()
Nillable, that is nil because it is missing.T - the typeNillablepublic static <T> Nillable<T> template()
Nillable, that is nil because it is a template value.T - the typeNillablepublic static <T> Nillable<T> unknown()
Nillable, that is nil because it is unknown.T - the typeNillablepublic static <T> Nillable<T> withheld()
Nillable, that is nil because it is withheld.T - the typeNillablepublic static <T> Nillable<T> of(T obj)
Nillable that is either present (if obj is not null), or absent.T - the typeobj - the object (may be null)NillableCopyright © 2015–2021 52North Initiative for Geospatial Open Source Software GmbH. All rights reserved.