T
- the instance typepublic abstract class Nillable<T> extends Object
isNil()
, isAbsent()
and
isPresent()
are mutually exclusive true
.Modifier and Type | Class and Description |
---|---|
private static class |
Nillable.Absent |
private static class |
Nillable.Nil |
private static class |
Nillable.Present<T> |
Constructor and Description |
---|
Nillable() |
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 com.google.common.base.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.
|
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. |
abstract <X> Nillable<X> |
transform(com.google.common.base.Function<? super T,X> fun)
Transforms this
Nillable to the target type. |
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
.nil
isPresent()
,
isAbsent()
public abstract boolean isPresent()
Nillable
is present.isNil()
,
isAbsent()
public abstract boolean isAbsent()
Nillable
is null
.null
isNil()
,
isPresent()
public abstract <X> Nillable<X> transform(com.google.common.base.Function<? super T,X> fun)
Nillable
to the target type.X
- the target typefun
- the transformation functionNillable
public boolean isNull()
Nillable
is null
.null
isAbsent()
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 com.google.common.base.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 objectNillable
NullPointerException
- if t
is null
public static <T> Nillable<T> absent()
Nillable
for a absent instance.T
- the typeNillable
public static <T> Nillable<T> nil(String reason)
Nillable
that is nil
because of optionally
supplied reason.T
- the typereason
- the reason (may be null
)Nillable
public static <T> Nillable<T> nil()
Nillable
that is nil
.T
- the typeNillable
public static <T> Nillable<T> inapplicable()
Nillable
, that is nil because it is inapplicable.T
- the typeNillable
public static <T> Nillable<T> missing()
Nillable
, that is nil because it is missing.T
- the typeNillable
public static <T> Nillable<T> template()
Nillable
, that is nil because it is a template
value.T
- the typeNillable
public static <T> Nillable<T> unknown()
Nillable
, that is nil because it is unknown.T
- the typeNillable
public static <T> Nillable<T> withheld()
Nillable
, that is nil because it is withheld.T
- the typeNillable
public 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
)Nillable
Copyright © 2012-2015 52north.org. All Rights Reserved.