public interface BiFunctor<T1,T2>
Modifier and Type | Method and Description |
---|---|
default <U1,U2> BiFunctor<U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2)
Cast two data types simulatanously.
|
<R1,R2> BiFunctor<R1,R2> |
bimap(java.util.function.Function<? super T1,? extends R1> fn1,
java.util.function.Function<? super T2,? extends R2> fn2)
Transform this BiFunctor, changing two value types at once.
|
default BiFunctor<T1,T2> |
bipeek(java.util.function.Consumer<? super T1> c1,
java.util.function.Consumer<? super T2> c2)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
default <R1,R2> BiFunctor<R1,R2> |
bitrampoline(java.util.function.Function<? super T1,? extends Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super T2,? extends Trampoline<? extends R2>> mapper2)
Perform a tail-call optimized recursive transformation operation across two data points simultaneously
|
<R1,R2> BiFunctor<R1,R2> bimap(java.util.function.Function<? super T1,? extends R1> fn1, java.util.function.Function<? super T2,? extends R2> fn2)
MapX<String,Integer> map = MapXs.of("hello",2);
MapX<String,Integer> transformedMap = map.bimap(s->s+" world",i->i*4);
//["hello world",8]
fn1
- transformation function for the first typefn2
- transformation function for the second typedefault BiFunctor<T1,T2> bipeek(java.util.function.Consumer<? super T1> c1, java.util.function.Consumer<? super T2> c2)
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
c1
- consumer for the first typec2
- consumer for the second typedefault <U1,U2> BiFunctor<U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
MapX<Animal,Food> map = MapXs.of(cow,grass);
MapX<Mamaml,Vegitation> herbervoreMammals = map.bicast(Mammal.class,Vegitation.class);
type1
- type2
- default <R1,R2> BiFunctor<R1,R2> bitrampoline(java.util.function.Function<? super T1,? extends Trampoline<? extends R1>> mapper1, java.util.function.Function<? super T2,? extends Trampoline<? extends R2>> mapper2)
mapper1
- transformation function for the first typemapper2
- transformation function for the second type