Modifier and Type | Method and Description |
---|---|
default <U> boolean |
corresponds(Iterable<U> that,
java.util.function.BiPredicate<? super T,? super U> predicate)
Tests whether every element of this iterable relates to the corresponding element of another iterable by
satisfying a test predicate.
|
default boolean |
eq(Object o)
A smoothing replacement for
equals . |
boolean |
equals(Object obj)
Clarifies that values have a proper equals() method implemented.
|
default boolean |
exists(java.util.function.Predicate<? super T> predicate)
Checks, if an element exists such that the predicate holds.
|
Option<L> |
filter(java.util.function.Predicate<? super L> predicate)
Returns
Some value of type L if this is a left projection of a Left value and the predicate
applies to the underlying value. |
<U> Either.LeftProjection<U,R> |
flatMap(java.util.function.Function<? super L,? extends Iterable<? extends U>> mapper)
FlatMaps the left value if the projected Either is a Left.
|
default boolean |
forAll(java.util.function.Predicate<? super T> predicate)
Checks, if the given predicate holds for all elements.
|
default void |
forEach(java.util.function.Consumer<? super T> action)
Performs an action on each element.
|
L |
get()
Gets the Left value or throws.
|
int |
hashCode()
Clarifies that values have a proper hashCode() method implemented.
|
boolean |
isEmpty()
Checks, this
Value is empty, i.e. |
boolean |
isSingletonType()
A left projection is a singleton type.
|
Iterator<L> |
iterator()
Returns a rich
javaslang.collection.Iterator . |
<U> Either.LeftProjection<U,R> |
map(java.util.function.Function<? super L,? extends U> mapper)
Maps the left value if the projected Either is a Left.
|
L |
orElse(L other)
Gets the Left value or an alternate value, if the projected Either is a Right.
|
L |
orElseGet(java.util.function.Function<? super R,? extends L> other)
Gets the Left value or an alternate value, if the projected Either is a Right.
|
void |
orElseRun(java.util.function.Consumer<? super R> action)
Runs an action in the case this is a projection on a Right value.
|
<X extends Throwable> |
orElseThrow(java.util.function.Function<? super R,X> exceptionFunction)
Gets the Left value or throws, if the projected Either is a Right.
|
Either.LeftProjection<L,R> |
peek(java.util.function.Consumer<? super L> action)
Applies the given action to the value if the projected either is a Left.
|
default void |
stderr()
Sends the string representations of this value to the standard error stream System.err.
|
default void |
stdout()
Sends the string representations of this value to the standard output stream System.out.
|
Either<L,R> |
toEither()
Returns the underlying either of this projection.
|
default Object[] |
toJavaArray()
Converts this value to an untyped Java array.
|
String |
toString()
Clarifies that values have a proper toString() method implemented.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
foldLeft, foldRight, get, getOption, ifDefined, ifDefined, ifEmpty, ifEmpty, isDefined, orElseGet, orElseThrow, orElseTry, out, out, toArray, toCharSeq, toJavaArray, toJavaList, toJavaMap, toJavaOptional, toJavaSet, toJavaStream, toLazy, toList, toMap, toOption, toQueue, toSet, toStack, toStream, toTree, toTry, toTry, toVector
fold, fold, foldLeft, foldMap, foldRight
lift, lift, lift, lift, lift, lift, lift, lift
spliterator
public boolean isEmpty()
Value
Value
is empty, i.e. if the underlying value is absent.public boolean isSingletonType()
isSingletonType
in interface Value<L>
true
public L get()
get
in interface Value<L>
NoSuchElementException
- if the underlying either of this LeftProjection is a Rightpublic L orElse(L other)
orElse
in interface Value<L>
other
- an alternative valueother
NoSuchElementException
- if the underlying either of this LeftProjection is a Rightpublic L orElseGet(java.util.function.Function<? super R,? extends L> other)
other
- a function which converts a Right value to an alternative Left valueother
by applying the Right value.public void orElseRun(java.util.function.Consumer<? super R> action)
action
- an action which consumes a Right valuepublic <X extends Throwable> L orElseThrow(java.util.function.Function<? super R,X> exceptionFunction) throws X extends Throwable
X
- a throwable typeexceptionFunction
- a function which creates an exception based on a Right valueexceptionFunction
by applying the Right value.X
- if the projected Either is a RightX extends Throwable
public Either<L,R> toEither()
public Option<L> filter(java.util.function.Predicate<? super L> predicate)
Some
value of type L if this is a left projection of a Left value and the predicate
applies to the underlying value.public <U> Either.LeftProjection<U,R> flatMap(java.util.function.Function<? super L,? extends Iterable<? extends U>> mapper)
public <U> Either.LeftProjection<U,R> map(java.util.function.Function<? super L,? extends U> mapper)
public Either.LeftProjection<L,R> peek(java.util.function.Consumer<? super L> action)
public boolean equals(Object obj)
Value
public int hashCode()
Value
See Object.hashCode().
public String toString()
Value
See Object.toString().
public <U> boolean corresponds(Iterable<U> that, java.util.function.BiPredicate<? super T,? super U> predicate)
U
- Component type of that iterablethat
- the other iterablepredicate
- the test predicate, which relates elements from both iterablestrue
if both iterables have the same length and predicate(x, y)
is true
for all corresponding elements x
of this iterable and y
of that
,
otherwise false
.public boolean eq(Object o)
equals
. It is similar to Scala's ==
but better in the way
that it is not limited to collection types, e.g. Some(1) eq List(1)
, None eq Failure(x)
etc.
In a nutshell: eq checks congruence of structures and equality of contained values.
Example:
// ((1, 2), ((3))) => structure: (()(())) values: 1, 2, 3
final Iterable<?> i1 = List.of(List.of(1, 2), Arrays.asList(List.of(3)));
final Iterable<?> i2 = Queue.of(Stream.of(1, 2), List.of(Lazy.of(() -> 3)));
assertThat(i1.eq(i2)).isTrue();
Semantics:
o == this : true
o instanceof javaslang.Iterable : iterable elements are eq, non-iterable elements equals, for all (o1, o2) in (this, o)
o instanceof java.lang.Iterable : this eq Iterator.of((java.lang.Iterable<?>) o);
otherwise : false
o
- An objectpublic boolean exists(java.util.function.Predicate<? super T> predicate)
predicate
- A PredicateNullPointerException
- if predicate
is nullpublic boolean forAll(java.util.function.Predicate<? super T> predicate)
predicate
- A PredicateNullPointerException
- if predicate
is nullpublic void forEach(java.util.function.Consumer<? super T> action)
forEach
in interface Iterable<T>
action
- A Consumer
NullPointerException
- if action
is nullpublic Object[] toJavaArray()
public void stderr()
IllegalStateException
- if PrintStream.checkError()
is true after writing to stderr.public void stdout()
IllegalStateException
- if PrintStream.checkError()
is true after writing to stdout.Copyright © 2015. All Rights Reserved.