public static class Ior.Primary<ST,PT> extends java.lang.Object implements Ior<ST,PT>
Ior.Both<ST,PT>, Ior.Instances, Ior.Primary<ST,PT>, Ior.Secondary<ST,PT>
Value.ValueImpl<T>
Convertable.SupplierToConvertable<T>
Fn0.FunctionalOperations<R>, Fn0.SupplierKind<R>
Constructor and Description |
---|
Primary() |
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> stAction,
java.util.function.Consumer<? super PT> ptAction)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
java.util.Optional<org.jooq.lambda.tuple.Tuple2<ST,PT>> |
both() |
<T2,R> Ior<ST,R> |
combine(Value<? extends T2> app,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
Lazily combine this ApplicativeFunctor with the supplied value via the supplied BiFunction
Example
|
Ior<ST,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 MonadicValue<? extends RT1>> mapper)
A flattening transformation operation (@see
Optional.flatMap(Function) |
PT |
get() |
boolean |
isBoth() |
boolean |
isPrimary() |
boolean |
isSecondary() |
<R> Ior<ST,R> |
map(java.util.function.Function<? super PT,? extends R> fn)
Transform this functor using the supplied transformation function
|
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
|
<LT1> Ior<LT1,PT> |
secondaryFlatMap(java.util.function.Function<? super ST,? extends Ior<LT1,PT>> mapper)
Perform a flatMap operation on the Secondary type
|
ST |
secondaryGet() |
<R> Ior<R,PT> |
secondaryMap(java.util.function.Function<? super ST,? extends R> fn)
Always map the Secondary type of this Ior if it is present using the provided transformation function
|
Ior<ST,PT> |
secondaryPeek(java.util.function.Consumer<? super ST> action)
Peek at the Secondary type value if present
|
java.util.Optional<ST> |
secondaryToOptional() |
Ior<ST,PT> |
secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends Ior<ST,PT>> fn)
A flatMap operation that keeps the Secondary and Primary types the same
|
Ior<ST,PT> |
secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn)
If this Ior contains the Secondary type only, map it's value so that it contains the Primary type only
If this Ior contains both types, this method has no effect in the default implementations
|
ReactiveSeq<ST> |
secondaryToStream() |
Value<ST> |
secondaryValue() |
Ior<PT,ST> |
swap() |
java.lang.String |
toString() |
Xor<ST,PT> |
toXor() |
Xor<ST,PT> |
toXorDropPrimary() |
<R> R |
visit(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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accumulatePrimary, accumulatePrimary, accumulatePrimary, accumulateSecondary, accumulateSecondary, accumulateSecondary, allTypeclasses, anyM, applyAny, arity, bicast, bitrampoline, both, both, bothValue, cast, coflatMap, combineEager, consumeAny, coproduct, filterNot, flatMapI, flatMapP, flatMapS, forEach2, forEach2, forEach3, forEach3, forEach4, forEach4, fromIterable, fromPublisher, isPresent, kindCokleisli, kindKleisli, mapM, narrowK, narrowK2, nest, nested, notNull, ofType, primary, product, retry, retry, secondary, sequencePrimary, sequenceSecondary, toIor, toXor, trampoline, unit, visitAny, visitAny, widen, zip, zip, zip, zip3, zip3, zip4, zip4, zipP, zipP, zipS, zipS, zipWith, zipWithP, zipWithS
apply, generate, iterate, iterator, newSubscriber, of, stream, subscribe, test, toEither, toEval, toEvalAlways, toEvalLater, toEvalNow, toLeft, toMaybe, toMaybeEager, toRight, toTry, toTry, toTry
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleUnsafe, startsWith, startsWithIterable, takeOne, xMatch
collect, fromSupplier, orElse, orElseGet, orElseThrow, toCompletableFuture, toCompletableFutureAsync, toFuture, toFutureAsync, toOptional, toStream, visit
public Xor<ST,PT> toXorDropPrimary()
toXorDropPrimary
in interface Ior<ST,PT>
public Ior<ST,PT> secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn)
Ior
secondaryToPrimayMap
in interface Ior<ST,PT>
fn
- Function to map secondary type to primarypublic <R> Ior<R,PT> secondaryMap(java.util.function.Function<? super ST,? extends R> fn)
Ior
secondaryMap
in interface Ior<ST,PT>
fn
- Transformation function for Secondary typespublic <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]
map
in interface Transformable<PT>
map
in interface MonadicValue<PT>
map
in interface Ior<ST,PT>
fn
- Transformation functionpublic Ior<ST,PT> secondaryPeek(java.util.function.Consumer<? super ST> action)
Ior
secondaryPeek
in interface Ior<ST,PT>
action
- Consumer to peek at the Secondary type valuepublic <R> R visit(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.primary(10)
.visit(secondary->"no", primary->"yes",(sec,pri)->"oops!")
//Ior["yes"]
Ior.secondary(90)
.visit(secondary->"no", primary->"yes",(sec,pri)->"oops!")
//Ior["no"]
Ior.both(10, "eek")
.visit(secondary->"no", primary->"yes",(sec,pri)->"oops!")
//Ior["oops!"]
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 Ior<ST,PT> filter(java.util.function.Predicate<? super PT> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
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 PT get()
public ST secondaryGet()
secondaryGet
in interface Ior<ST,PT>
public java.util.Optional<ST> secondaryToOptional()
secondaryToOptional
in interface Ior<ST,PT>
public ReactiveSeq<ST> secondaryToStream()
secondaryToStream
in interface Ior<ST,PT>
public <RT1> Ior<ST,RT1> flatMap(java.util.function.Function<? super PT,? extends MonadicValue<? extends RT1>> mapper)
MonadicValue
Optional.flatMap(Function)
Eval.now(1).map(i->i+2).flatMap(i->Eval.later(()->i*3);
//Eval[9]
public <LT1> Ior<LT1,PT> secondaryFlatMap(java.util.function.Function<? super ST,? extends Ior<LT1,PT>> mapper)
Ior
secondaryFlatMap
in interface Ior<ST,PT>
mapper
- Flattening transformation functionpublic Ior<ST,PT> secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends Ior<ST,PT>> fn)
Ior
secondaryToPrimayFlatMap
in interface Ior<ST,PT>
fn
- Transformation functionpublic Ior<ST,PT> bipeek(java.util.function.Consumer<? super ST> stAction, java.util.function.Consumer<? super PT> ptAction)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
public boolean isPrimary()
public boolean isSecondary()
isSecondary
in interface Ior<ST,PT>
public boolean isBoth()
public Value<ST> secondaryValue()
secondaryValue
in interface Ior<ST,PT>
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String mkString()
Value
public <T2,R> Ior<ST,R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
MonadicValue
Maybe<Integer> some = Maybe.just(10);
just.combine(Eval.now(20), this::add);
//Some[30]
Maybe<Integer> none = Maybe.none();
none.combine(Eval.now(20), this::add);
//None