|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> ru.yandex.bolts.collection.impl.AbstractCollectionF<E> ru.yandex.bolts.collection.impl.AbstractListF<T> ru.yandex.bolts.collection.Option<T>
public abstract class Option<T>
Port of scala Option.
Option
,
Serialized FormNested Class Summary | |
---|---|
static class |
Option.None<T>
None. |
static class |
Option.Some<T>
Some. |
Field Summary |
---|
Fields inherited from class ru.yandex.bolts.collection.impl.AbstractListF |
---|
modCount |
Method Summary | ||
---|---|---|
Option<T> |
filter(Function1B<? super T> p)
Return collection with only elements that match predicate. |
|
|
flatMap(Function<? super T,? extends Collection<B>> f)
Flat map |
|
|
flatMapO(Function<? super T,Option<U>> f)
Flat map variant that accept mapper that returns Option instead of Collection |
|
abstract T |
get()
Get the value. |
|
T |
get(int index)
Answers the element at the specified location in this List. |
|
static
|
getF()
Delegate to get() . |
|
static
|
getM()
Deprecated. |
|
T |
getOrElse(Function0<T> u)
If this is some return value of this, or evaluate function and return it value otherwise. |
|
T |
getOrElse(T u)
If this is some return value of this, or return given value otherwise. |
|
T |
getOrNull()
getOrElse(null) , but works with types better. |
|
|
getOrThrow(E e)
Throw specified exception if isEmpty() . |
|
|
getOrThrow(Function0<E> e)
Throw specified exception if isEmpty() . |
|
T |
getOrThrow(String message)
Throw exception with specified message if this is empty |
|
T |
getOrThrow(String message,
Object param)
Get or throw exception if this is empty. |
|
boolean |
isDefined()
true iff this is some. |
|
static
|
isDefinedF()
Delegate to isDefined() . |
|
static
|
isDefinedP()
Deprecated. |
|
abstract boolean |
isEmpty()
true iff this is none. |
|
static
|
isEmptyF()
Delegate to isEmpty() . |
|
static
|
isEmptyP()
Deprecated. |
|
|
map(Function<? super T,U> f)
Map |
|
static
|
none()
Return singleton none object. |
|
static
|
notNull(T x)
Some if not null, None otherwise. |
|
static
|
notNullF()
Delegate to notNull(Object) . |
|
static
|
notNullM()
Deprecated. |
|
Option<T> |
orElse(Function0<Option<T>> elseOption)
this if this is some, or evaluate function and return option otherwise. |
|
Option<T> |
orElse(Option<T> elseOption)
this if this is some, or given option otherwise. |
|
int |
size()
|
|
static
|
some(T x)
Construct some containing given value. |
|
SetF<T> |
toSet()
|
|
|
uncheckedCast()
This object with different type parameters |
|
SetF<T> |
unique()
Return set of elements of this |
Methods inherited from class ru.yandex.bolts.collection.impl.AbstractListF |
---|
add, add, addAll, clear, collect, drop, emptyCollection, emptyList, equals, filter2, first, firstO, hashCode, honestPlus, indexOf, iterator, last, lastIndexOf, lastO, length, listIterator, listIterator, newMutableCollection, plus, plus, plus, plus, plus1, readOnlyIterator, readOnlyListIterator, remove, removeRange, reverse, reverseIterator, set, subList, take, toList, unmodifiable, zip, zipWithIndex |
Methods inherited from class ru.yandex.bolts.collection.impl.AbstractCollectionF |
---|
addAll, addF, addOp, containsF, containsP, eq, equals, exists, find, foldLeft, foldRight, forAll, forEach, groupBy, max, max, min, min, mkString, mkString, reduceLeft, reduceRight, single, singleO, singletonCollection, sort, sort, sortBy, sortByDesc, toArray, toBooleanArray, toByteArray, toCharArray, toDoubleArray, toFloatArray, toIntArray, toLongArray, toMap, toMapMappingToKey, toMapMappingToValue, toShortArray |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ru.yandex.bolts.collection.CollectionF |
---|
addAll, addF, addOp, containsF, containsP, groupBy, max, max, min, min, single, singleO, sort, sort, sortBy, sortByDesc, toArray, toBooleanArray, toByteArray, toCharArray, toDoubleArray, toFloatArray, toIntArray, toLongArray, toMap, toMapMappingToKey, toMapMappingToValue, toShortArray |
Methods inherited from interface ru.yandex.bolts.collection.IterableF |
---|
exists, find, foldLeft, foldRight, forAll, forEach, mkString, mkString, reduceLeft, reduceRight |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray |
Method Detail |
---|
public abstract boolean isEmpty()
true
iff this is none.
isEmpty
in interface Collection<T>
isEmpty
in interface List<T>
isEmpty
in class AbstractCollection<T>
public final boolean isDefined()
true
iff this is some.
public abstract T get() throws NoSuchElementException
NoSuchElementException
- if this is none.public final T getOrElse(T u)
public final T getOrElse(Function0<T> u)
public final T getOrNull()
getOrElse(null)
, but works with types better.
public final Option<T> orElse(Option<T> elseOption)
this
if this is some, or given option otherwise.
public final Option<T> orElse(Function0<Option<T>> elseOption)
this
if this is some, or evaluate function and return option otherwise.
public final <E extends Throwable> T getOrThrow(E e) throws E extends Throwable
isEmpty()
.
E extends Throwable
public final <E extends Throwable> T getOrThrow(Function0<E> e) throws E extends Throwable
isEmpty()
.
E extends Throwable
public final T getOrThrow(String message) throws RuntimeException
RuntimeException
public final T getOrThrow(String message, Object param) throws RuntimeException
RuntimeException
public int size()
size
in interface Collection<T>
size
in interface List<T>
size
in class AbstractCollection<T>
public T get(int index)
AbstractListF
get
in interface List<T>
get
in class AbstractListF<T>
index
- the index of the element to return
public final <U> Option<U> map(Function<? super T,U> f)
CollectionF
map
in interface CollectionF<T>
map
in class AbstractCollectionF<T>
public final <U> Option<U> flatMapO(Function<? super T,Option<U>> f)
CollectionF
flatMapO
in interface CollectionF<T>
flatMapO
in class AbstractCollectionF<T>
public <B> ListF<B> flatMap(Function<? super T,? extends Collection<B>> f)
CollectionF
flatMap
in interface CollectionF<T>
flatMap
in class AbstractCollectionF<T>
public final Option<T> filter(Function1B<? super T> p)
CollectionF
filter
in interface CollectionF<T>
filter
in interface ListF<T>
filter
in class AbstractListF<T>
public final SetF<T> toSet()
public SetF<T> unique()
CollectionF
unique
in interface CollectionF<T>
unique
in class AbstractCollectionF<T>
public <F> Option<F> uncheckedCast()
uncheckedCast
in interface CollectionF<T>
uncheckedCast
in interface IterableF<T>
uncheckedCast
in interface ListF<T>
uncheckedCast
in class AbstractListF<T>
public static <T> Option<T> none()
public static <T> Option<T> some(T x)
public static <T> Option<T> notNull(T x)
public static <U> Function1B<Option<U>> isDefinedP()
public static <U> Function1B<Option<U>> isDefinedF()
isDefined()
.
public static <U> Function1B<Option<U>> isEmptyP()
public static <U> Function1B<Option<U>> isEmptyF()
isEmpty()
.
public static <T> Function<T,Option<T>> notNullM()
public static <T> Function<T,Option<T>> notNullF()
notNull(Object)
.
public static <U> Function<Option<U>,U> getM()
public static <U> Function<Option<U>,U> getF()
get()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |