|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.Option<T>
net.sf.staccatocommons.lang.Some<T>
T - @Value
@Conditionally(value={net.sf.staccatocommons.restrictions.value.Immutable.class,java.io.Serializable.class})
public final class Some<T>
A defined Option, that is, an option that holds a value.
Option,
Serialized Form| Constructor Summary | |
|---|---|
Some(T value)
Creates a Some instance with the given value |
|
| Method Summary | ||
|---|---|---|
boolean |
contains(T element)
|
|
boolean |
equals(Object obj)
|
|
int |
hashCode()
|
|
void |
ifDefined(net.sf.staccatocommons.defs.Executable<? super T> block)
Executed the given block if this option is defined |
|
boolean |
isDefined()
Returns if the value has been defined or not. |
|
boolean |
isEmpty()
|
|
Iterator<T> |
iterator()
|
|
int |
size()
|
|
static
|
some(T value)
|
|
static
|
someNull()
|
|
String |
toString()
|
|
T |
value()
Gets the optional value, if defined, or throws an NoSuchElementException, otherwise. |
|
T |
valueOrElse(T ifUndefined)
Returns the value of this Option, or the provided object if
undefined |
|
T |
valueOrElse(net.sf.staccatocommons.defs.Thunk<? extends T> ifUndefined)
Returns the value of this Option, or the provided object if
undefined |
|
T |
valueOrNull()
Returns the value of this Option, or null, if
undefined. |
|
| Methods inherited from class net.sf.staccatocommons.lang.Option |
|---|
filter, forEach, isUndefined, map, none, nullToNone |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Some(T value)
value - the value wrapped. Nullable.| Method Detail |
|---|
public T value()
OptionNoSuchElementException, otherwise.
value in interface net.sf.staccatocommons.defs.Thunk<T>value in class Option<T>public boolean isDefined()
Option
isDefined in class Option<T>public T valueOrElse(T ifUndefined)
OptionOption, or the provided object if
undefined
valueOrElse in class Option<T>ifUndefined - the return value in case this Option is undefined
this.value() if defined, other otherwisepublic T valueOrElse(net.sf.staccatocommons.defs.Thunk<? extends T> ifUndefined)
OptionOption, or the provided object if
undefined
valueOrElse in class Option<T>ifUndefined - the thunk of the return value in case this Option is
undefined
this.value() if defined, other.value()
otherwisepublic T valueOrNull()
OptionOption, or null, if
undefined.
valueOrNull in class Option<T>this.value() if defined, or null,
otherwise
public void ifDefined(@NonNull
net.sf.staccatocommons.defs.Executable<? super T> block)
Option
ifDefined in class Option<T>public Iterator<T> iterator()
public boolean contains(T element)
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic int size()
public boolean isEmpty()
public String toString()
toString in class Objectpublic static <T> Some<T> some(T value)
public static <T> Some<T> someNull()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||