|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface OptionalUtils
Utilities for working with Optional objects.
| Method Summary | ||
|---|---|---|
|
executeOnSome(Optional<T> optional,
Closure<T> closure)
Executes a given closure on an optional object. |
|
|
filterNones(Collection<Optional<T>> c)
Filters out the None elements in a collection and returns a
collection of the objects inside the remaining Some
elements. |
|
|
isNone(Optional<T> optional)
Returns whether an optional object is a None object. |
|
boolean |
isSome(Optional optional)
Returns whether an optional object is a Some object. |
|
Optional |
optionalOf(Object object)
Returns an Optional from a possible null
object. |
|
|
someObject(Optional<T> optional)
Returns the object stored in an optional object if one exists. |
|
|
transformSome(Optional<T1> optional,
Transformer<T1,T2> transformer)
Returns an Optional object created by transforming the
contents of another Optional object. |
|
| Method Detail |
|---|
Optional optionalOf(Object object)
Optional from a possible null
object. If the object is null, None is
returned. Otherwise, a Some object containing the given
object is returned.
object - The object, possible null.
object is null, then None
is returned, otherwise a Some containing
object is returned.
<T1,T2> Optional<T2> transformSome(Optional<T1> optional,
Transformer<T1,T2> transformer)
Optional object created by transforming the
contents of another Optional object. If the given
Optional is a None, then None is
returned. If the given Optional is a Some,
then the contents of the Some are transformed and the
result wrapped in a Some is returned.
optional - The Optional object to be transformed.transformer - The transformer used to transform the contents of a
Some object.
Optional object whose contents, if they exists,
have been transformed by the given transformer.<T> boolean isNone(Optional<T> optional)
None object.
optional - The optional object.
optional is a None, false
otherwise.boolean isSome(Optional optional)
Some object.
optional - The optional object.
optional is a Some, false
otherwise.
<T> T someObject(Optional<T> optional)
throws IllegalArgumentException
optional - The optional object.
IllegalArgumentException - If the optional object is not a Some object.
<T> void executeOnSome(Optional<T> optional,
Closure<T> closure)
T - The type of object held by the optional object.optional - The optional object.closure - The closure to execute on the object held by the optional object, if
it exists.<T> Collection<T> filterNones(Collection<Optional<T>> c)
None elements in a collection and returns a
collection of the objects inside the remaining Some
elements.
T - The type of the objects inside the some objects.c - The collection to filter.
T elements.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||