public static class Ior.Both<ST,PT> extends java.lang.Object implements Ior<ST,PT>
Ior.Both<ST,PT>, Ior.Primary<ST,PT>, Ior.Secondary<ST,PT>
Constructor and Description |
---|
Both() |
Modifier and Type | Method and Description |
---|---|
<R1,R2> Ior<R1,R2> |
bimap(java.util.function.Function<? super ST,? extends R1> fn1,
java.util.function.Function<? super PT,? extends R2> fn2)
Transform this BiTransformable, changing two value types at once.
|
Ior<ST,PT> |
bipeek(java.util.function.Consumer<? super ST> actionA,
java.util.function.Consumer<? super PT> actionB)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
Option<Tuple2<ST,PT>> |
both() |
Option<PT> |
filter(java.util.function.Predicate<? super PT> test)
Keep only elements for which the supplied predicates hold
e.g.
|
<RT1> Ior<ST,RT1> |
flatMap(java.util.function.Function<? super PT,? extends Ior<? extends ST,? extends RT1>> mapper) |
<LT1> Ior<LT1,PT> |
flatMapLeft(java.util.function.Function<? super ST,? extends Ior<LT1,PT>> mapper)
Perform a flatMap operation on the Secondary type
|
<R> R |
fold(java.util.function.Function<? super PT,? extends R> present,
java.util.function.Supplier<? extends R> absent) |
<R> R |
fold(java.util.function.Function<? super ST,? extends R> secondary,
java.util.function.Function<? super PT,? extends R> primary,
java.util.function.BiFunction<? super ST,? super PT,? extends R> both)
Visitor pattern for this Ior.
|
Option<PT> |
get() |
Option<ST> |
getLeft() |
boolean |
isBoth() |
boolean |
isLeft() |
boolean |
isRight() |
java.util.Iterator<PT> |
iterator() |
<R> Ior<ST,R> |
map(java.util.function.Function<? super PT,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> Ior<R,PT> |
mapLeft(java.util.function.Function<? super ST,? extends R> fn) |
java.lang.String |
mkString()
Returns the class name and the name of the subclass, if there is any value, the value is showed between square brackets.
|
Ior<ST,PT> |
peek(java.util.function.Consumer<? super PT> action)
Peek at the current value of this Transformable, without transforming it
|
Ior<ST,PT> |
peekLeft(java.util.function.Consumer<? super ST> action) |
Ior<ST,PT> |
recover(PT value) |
Ior<ST,PT> |
recover(java.util.function.Supplier<? extends PT> value) |
Ior<ST,PT> |
recoverWith(java.util.function.Supplier<? extends Ior<ST,PT>> fn) |
ReactiveSeq<PT> |
stream() |
Ior<PT,ST> |
swap() |
Either<ST,PT> |
toEither() |
Either<ST,PT> |
toEitherDropRight() |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accumulateLeft, accumulateLeft, accumulateLeft, accumulateRight, accumulateRight, accumulateRight, applyAny, arity, coflatMap, consumeAny, filterNot, foldAny, forEach2, forEach3, forEach4, fromIterable, fromPublisher, isPresent, left, narrowK, narrowK2, nest, notNull, ofType, right, sequence, sequenceLeft, sequenceRight, toEither, traverse, unit, visitAny, visitAny, widen, zip, zip
orElseUse, orElseUse
asSupplier, collect, fold, forEach, generate, iterate, nonEmptyList, nonEmptyListGet, orElse, orElseGet, print, print, printErr, printOut, subscribe, toLazyEither, toLeft, toMaybe, toOption, toOptional, toRight, toTry, toTry, toTry
public ReactiveSeq<PT> stream()
public Ior<ST,PT> recoverWith(java.util.function.Supplier<? extends Ior<ST,PT>> fn)
recoverWith
in interface Ior<ST,PT>
public java.util.Iterator<PT> iterator()
public Either<ST,PT> toEitherDropRight()
toEitherDropRight
in interface Ior<ST,PT>
public <R> Ior<ST,R> map(java.util.function.Function<? super PT,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
public Ior<ST,PT> peek(java.util.function.Consumer<? super PT> action)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
public Option<PT> filter(java.util.function.Predicate<? super PT> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public <R> R fold(java.util.function.Function<? super ST,? extends R> secondary, java.util.function.Function<? super PT,? extends R> primary, java.util.function.BiFunction<? super ST,? super PT,? extends R> both)
Ior
Ior.right(10)
.visit(left->"no", right->"yes",(sec,pri)->"oops!")
//Ior["yes"]
Ior.left(90)
.visit(left->"no", right->"yes",(sec,pri)->"oops!")
//Ior["no"]
Ior.both(10, "eek")
.visit(left->"no", right->"yes",(sec,pri)->"oops!")
//Ior["oops!"]
public <RT1> Ior<ST,RT1> flatMap(java.util.function.Function<? super PT,? extends Ior<? extends ST,? extends RT1>> mapper)
public <LT1> Ior<LT1,PT> flatMapLeft(java.util.function.Function<? super ST,? extends Ior<LT1,PT>> mapper)
Ior
flatMapLeft
in interface Ior<ST,PT>
mapper
- Flattening transformation functionpublic Ior<ST,PT> bipeek(java.util.function.Consumer<? super ST> actionA, java.util.function.Consumer<? super PT> actionB)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
public <R1,R2> Ior<R1,R2> bimap(java.util.function.Function<? super ST,? extends R1> fn1, java.util.function.Function<? super PT,? extends R2> fn2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
MapX<String,Integer> transformedMap = map.bimap(s->s+" world",i->i*4);
//["hello world",8]
public boolean isRight()
public boolean isLeft()
public boolean isBoth()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String mkString()
Value