|
GridGain 4.3.1e
Enterprise "Big Data" Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.lang.GridLambdaAdapter
org.gridgain.grid.lang.GridAbsPredicate
org.gridgain.grid.lang.GridOpt<T>
public class GridOpt<T>
This class provide limited version of Scala Option class. It defines an optional
reference value (i.e. nullable value in Java). Using this class has two advantages: it
indicates to the caller that returned reference can be null, and it gently
forces the caller to check for it before using that reference. Note that calling
method GridOpt.get() on the object whose method GridOpt.isNone() returns true will
produce IllegalArgumentException exception.
Note that this class also implements Iterable interface so it can be used in
monadic way with various method in GridFunc class. If this option's GridOpt.isNone()
method returns true the iterator will be empty (which can be safely passed into any
method that expects the iterable object). If this option's GridOpt.isSome() method returns
true then iterator will have just one value (i.e. the value returned by GridOpt.get()
method.
GridNullOpt,
GridFunc.opt(GridOpt, GridInClosure),
GridFunc.opt(GridOpt, GridClosure, Object),
Serialized Form
![]() |
![]() |
| Method Summary | ||
|---|---|---|
boolean |
apply()
Predicate body. |
|
int |
arity()
Gets size of this product. |
|
T |
get()
Gets a non- null value. |
|
T |
getOrElse(T dflt)
Gets value if GridOpt.isSome(), otherwise given default value. |
|
boolean |
isNone()
Tests whether this option has a null value. |
|
boolean |
isSome()
Tests whether this option has a non- null value. |
|
Iterator<T> |
iterator()
|
|
static
|
make(T t)
Factory method that returns a non- null option if given value is not null, or
null option otherwise. |
|
static
|
none()
Factory method that creates a null option. |
|
GridOpt<T> |
orElse(GridOpt<T> o)
If GridOpt.isSome() returns this, otherwise given option. |
|
T |
part(int n)
Gets n th part or element for this product. |
|
static
|
some(T t)
Factory method that creates a non- null option with given value. |
|
String |
toString()
|
|
| Methods inherited from class org.gridgain.grid.lang.GridAbsPredicate |
|---|
andThen, andThen, andThen, uncurry, uncurry2, uncurry3 |
| Methods inherited from class org.gridgain.grid.lang.GridLambdaAdapter |
|---|
classLoader, deployClass, peerDeployLike |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public Iterator<T> iterator()
iterator in interface Iterable<T>public T part(int n)
th part or element for this product.
part in interface GridTypedProduct<T>n - Zero-based index of the part.
th part or element for this product.public int arity()
arity in interface GridTypedProduct<T>public boolean apply()
apply in class GridAbsPredicatepublic boolean isSome()
null value.
true if this option has a non-null value, false otherwise.public boolean isNone()
null value.
true if this option has a null value, false otherwise.public T get()
null value. If this option contains a null value this
method will throw IllegalArgumentException exception. Note that this method
will never return null.
IllegalArgumentException - Thrown in case if this option contains a null value.
null value.public GridOpt<T> orElse(GridOpt<T> o)
GridOpt.isSome() returns this, otherwise given option.
o - Option to return if isNone().
GridOpt.isSome() returns this, otherwise given option.public T getOrElse(T dflt)
GridOpt.isSome(), otherwise given default value.
dflt - Default value to return if isNone().
GridOpt.isSome(), otherwise given default value.public static <T> GridOpt<T> some(T t)
null option with given value.
IllegalArgumentException - Thrown if given value is null.T - Type of the value.t - A non-null value.
null value.public static <T> GridOpt<T> make(T t)
null option if given value is not null, or
null option otherwise.
T - Type of the option value.t - Option value (may be null).
public static <T> GridOpt<T> none()
null option. Note that this method
returns predefined static final instance.
null value.public String toString()
toString in class Object
|
GridGain 4.3.1e
Enterprise "Big Data" Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - In-Memory Big Data
|
|
|