com.aol.cyclops.reactor.Reactor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclops-reactor Show documentation
Show all versions of cyclops-reactor Show documentation
Converters and Comprehenders for Reactor
package com.aol.cyclops.reactor;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.reactivestreams.Publisher;
import com.aol.cyclops.control.AnyM;
import com.aol.cyclops.control.For;
import com.aol.cyclops.control.FutureW;
import com.aol.cyclops.control.ReactiveSeq;
import com.aol.cyclops.control.monads.transformers.FutureWT;
import com.aol.cyclops.control.monads.transformers.seq.FutureWTSeq;
import com.aol.cyclops.reactor.transformer.FluxT;
import com.aol.cyclops.reactor.transformer.FluxTSeq;
import com.aol.cyclops.types.anyM.AnyMSeq;
import com.aol.cyclops.types.anyM.AnyMValue;
import com.aol.cyclops.util.function.QuadFunction;
import com.aol.cyclops.util.function.TriFunction;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public interface Reactor {
public static AnyMSeq fromFluxT(FluxT flux) {
return AnyM.ofSeq(flux);
}
public static AnyMSeq flux(Flux flux) {
return AnyM.ofSeq(flux);
}
public static FluxTSeq fluxT(Publisher> nested) {
return FluxT.fromPublisher(nested);
}
public static AnyMValue mono(Mono mono) {
return AnyM.ofValue(mono);
}
public static FutureWTSeq monoT(Publisher> nested) {
return FutureWT.fromPublisher(Flux.from(nested)
.map(f -> FutureW.of(f.toFuture())));
}
public interface ForFlux {
static Flux each4(Flux extends T1> value1,
Function super T1, ? extends Flux> value2,
BiFunction super T1, ? super R1, ? extends Flux> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends Flux> value4,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(flux(value1))
.anyM(a -> flux(value2.apply(a)))
.anyM(a -> b -> flux(value3.apply(a, b)))
.anyM(a -> b -> c -> flux(value4.apply(a, b, c)))
.yield4(yieldingFunction)
.unwrap())
.unwrap();
}
static Flux each4(Flux extends T1> value1,
Function super T1, ? extends Flux> value2,
BiFunction super T1, ? super R1, ? extends Flux> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends Flux> value4,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, Boolean> filterFunction,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(flux(value1))
.anyM(a -> flux(value2.apply(a)))
.anyM(a -> b -> flux(value3.apply(a, b)))
.anyM(a -> b -> c -> flux(value4.apply(a, b, c)))
.filter(a -> b -> c -> d -> filterFunction.apply(a, b, c, d))
.yield4(yieldingFunction)
.unwrap())
.unwrap();
}
static Flux each3(Flux extends T1> value1,
Function super T1, ? extends Flux> value2,
BiFunction super T1, ? super R1, ? extends Flux> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(flux(value1))
.anyM(a -> flux(value2.apply(a)))
.anyM(a -> b -> flux(value3.apply(a, b)))
.yield3(yieldingFunction)
.unwrap())
.unwrap();
}
static Flux each3(Flux extends T1> value1,
Function super T1, ? extends Flux> value2,
BiFunction super T1, ? super R1, ? extends Flux> value3,
TriFunction super T1, ? super R1, ? super R2, Boolean> filterFunction,
TriFunction super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(flux(value1))
.anyM(a -> flux(value2.apply(a)))
.anyM(a -> b -> flux(value3.apply(a, b)))
.filter(a -> b -> c -> filterFunction.apply(a, b, c))
.yield3(yieldingFunction)
.unwrap())
.unwrap();
}
static Flux each2(Flux extends T> value1, Function super T, Flux> value2,
BiFunction super T, ? super R1, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(flux(value1))
.anyM(a -> flux(value2.apply(a)))
.yield2(yieldingFunction)
.unwrap())
.unwrap();
}
static Flux each2(Flux extends T> value1, Function super T, ? extends Flux> value2,
BiFunction super T, ? super R1, Boolean> filterFunction,
BiFunction super T, ? super R1, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(flux(value1))
.anyM(a -> flux(value2.apply(a)))
.filter(a -> b -> filterFunction.apply(a, b))
.yield2(yieldingFunction)
.unwrap())
.unwrap();
}
}
public interface ForFluxTransformer {
static FluxT each4(FluxT extends T1> value1,
Function super T1, ? extends FluxT> value2,
BiFunction super T1, ? super R1, ? extends FluxT> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends FluxT> value4,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(fromFluxT(value1))
.anyM(a -> fromFluxT(value2.apply(a)))
.anyM(a -> b -> fromFluxT(value3.apply(a, b)))
.anyM(a -> b -> c -> fromFluxT(value4.apply(a, b, c)))
.yield4(yieldingFunction)
.unwrap())
.unwrap();
}
static FluxT each4(FluxT extends T1> value1,
Function super T1, ? extends FluxT> value2,
BiFunction super T1, ? super R1, ? extends FluxT> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends FluxT> value4,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, Boolean> filterFunction,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(fromFluxT(value1))
.anyM(a -> fromFluxT(value2.apply(a)))
.anyM(a -> b -> fromFluxT(value3.apply(a, b)))
.anyM(a -> b -> c -> fromFluxT(value4.apply(a, b, c)))
.filter(a -> b -> c -> d -> filterFunction.apply(a, b, c, d))
.yield4(yieldingFunction)
.unwrap())
.unwrap();
}
static FluxT each3(FluxT extends T1> value1,
Function super T1, ? extends FluxT> value2,
BiFunction super T1, ? super R1, ? extends FluxT> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(fromFluxT(value1))
.anyM(a -> fromFluxT(value2.apply(a)))
.anyM(a -> b -> fromFluxT(value3.apply(a, b)))
.yield3(yieldingFunction)
.unwrap())
.unwrap();
}
static FluxT each3(FluxT extends T1> value1,
Function super T1, ? extends FluxT> value2,
BiFunction super T1, ? super R1, ? extends FluxT> value3,
TriFunction super T1, ? super R1, ? super R2, Boolean> filterFunction,
TriFunction super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(fromFluxT(value1))
.anyM(a -> fromFluxT(value2.apply(a)))
.anyM(a -> b -> fromFluxT(value3.apply(a, b)))
.filter(a -> b -> c -> filterFunction.apply(a, b, c))
.yield3(yieldingFunction)
.unwrap())
.unwrap();
}
static FluxT each2(FluxT extends T> value1, Function super T, FluxT> value2,
BiFunction super T, ? super R1, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(fromFluxT(value1))
.anyM(a -> fromFluxT(value2.apply(a)))
.yield2(yieldingFunction)
.unwrap())
.unwrap();
}
static FluxT each2(FluxT extends T> value1, Function super T, ? extends FluxT> value2,
BiFunction super T, ? super R1, Boolean> filterFunction,
BiFunction super T, ? super R1, ? extends R> yieldingFunction) {
return AnyM.ofSeq(For.anyM(fromFluxT(value1))
.anyM(a -> fromFluxT(value2.apply(a)))
.filter(a -> b -> filterFunction.apply(a, b))
.yield2(yieldingFunction)
.unwrap())
.unwrap();
}
}
public interface ForMono {
static Mono each4(Mono extends T1> value1,
Function super T1, ? extends Mono> value2,
BiFunction super T1, ? super R1, ? extends Mono> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends Mono> value4,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction) {
return AnyM.ofValue(For.anyM(mono(value1))
.anyM(a -> mono(value2.apply(a)))
.anyM(a -> b -> mono(value3.apply(a, b)))
.anyM(a -> b -> c -> mono(value4.apply(a, b, c)))
.yield4(yieldingFunction)
.unwrap())
.unwrap();
}
static Mono each4(Mono extends T1> value1,
Function super T1, ? extends Mono> value2,
BiFunction super T1, ? super R1, ? extends Mono> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends Mono> value4,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, Boolean> filterFunction,
QuadFunction super T1, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction) {
return AnyM.ofValue(For.anyM(mono(value1))
.anyM(a -> mono(value2.apply(a)))
.anyM(a -> b -> mono(value3.apply(a, b)))
.anyM(a -> b -> c -> mono(value4.apply(a, b, c)))
.filter(a -> b -> c -> d -> filterFunction.apply(a, b, c, d))
.yield4(yieldingFunction)
.unwrap())
.unwrap();
}
static Mono each3(Mono extends T1> value1,
Function super T1, ? extends Mono> value2,
BiFunction super T1, ? super R1, ? extends Mono> value3,
TriFunction super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) {
return AnyM.ofValue(For.anyM(mono(value1))
.anyM(a -> mono(value2.apply(a)))
.anyM(a -> b -> mono(value3.apply(a, b)))
.yield3(yieldingFunction)
.unwrap())
.unwrap();
}
static Mono each3(Mono extends T1> value1,
Function super T1, ? extends Mono> value2,
BiFunction super T1, ? super R1, ? extends Mono> value3,
TriFunction super T1, ? super R1, ? super R2, Boolean> filterFunction,
TriFunction super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) {
return AnyM.ofValue(For.anyM(mono(value1))
.anyM(a -> mono(value2.apply(a)))
.anyM(a -> b -> mono(value3.apply(a, b)))
.filter(a -> b -> c -> filterFunction.apply(a, b, c))
.yield3(yieldingFunction)
.unwrap())
.unwrap();
}
static Mono each2(Mono extends T> value1, Function super T, Mono> value2,
BiFunction super T, ? super R1, ? extends R> yieldingFunction) {
return AnyM.ofValue(For.anyM(mono(value1))
.anyM(a -> mono(value2.apply(a)))
.yield2(yieldingFunction)
.unwrap())
.unwrap();
}
static Mono each2(Mono extends T> value1, Function super T, ? extends Mono> value2,
BiFunction super T, ? super R1, Boolean> filterFunction,
BiFunction super T, ? super R1, ? extends R> yieldingFunction) {
return AnyM.ofValue(For.anyM(mono(value1))
.anyM(a -> mono(value2.apply(a)))
.filter(a -> b -> filterFunction.apply(a, b))
.yield2(yieldingFunction)
.unwrap())
.unwrap();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy