F
- public interface FeatureToggle<F> extends java.util.function.Supplier<F>, MonadicValue1<F>, Filterable<F>, Functor<F>, ApplicativeFunctor<F>, Matchable.ValueAndOptionalMatcher<F>
Modifier and Type | Interface and Description |
---|---|
static class |
FeatureToggle.Disabled<F>
An disabled switch
|
static class |
FeatureToggle.Enabled<F>
An enabled switch
|
ApplicativeFunctor.Applicatives, ApplicativeFunctor.ApplyFunctions<T>
Value.ValueImpl<T>
Convertable.SupplierToConvertable<T>
Modifier and Type | Method and Description |
---|---|
AnyMValue<F> |
anyM() |
AnyM<F> |
anyMDisabled() |
AnyM<F> |
anyMEnabled() |
default <U> FeatureToggle<U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
default <R> FeatureToggle<R> |
coflatMap(java.util.function.Function<? super MonadicValue<F>,R> mapper) |
default <T2,R> FeatureToggle<R> |
combine(Value<? extends T2> app,
java.util.function.BiFunction<? super F,? super T2,? extends R> fn)
Apply a function across to values at once.
|
default FeatureToggle<F> |
combineEager(Monoid<F> monoid,
MonadicValue<? extends F> v2)
Eagerly combine two MonadicValues using the supplied monoid (@see ApplicativeFunctor for type appropraite i.e.
|
default FeatureToggle.Disabled<F> |
disable() |
static <F> FeatureToggle.Disabled<F> |
disable(F f)
Create a new disabled switch
|
default FeatureToggle.Enabled<F> |
enable() |
static <F> FeatureToggle.Enabled<F> |
enable(F f)
Create a new enabled switch
|
default FeatureToggle<F> |
filter(java.util.function.Predicate<? super F> p)
Filter this Switch.
|
default FeatureToggle<F> |
filterNot(java.util.function.Predicate<? super F> fn)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
default <X> FeatureToggle<X> |
flatMap(java.util.function.Function<? super F,? extends MonadicValue<? extends X>> flatMapper) |
default FeatureToggle<F> |
flip() |
default void |
forEach(java.util.function.Consumer<? super F> consumer)
Iterate over value in switch (single value, so one iteration)
|
static <F> FeatureToggle<F> |
from(FeatureToggle<F> from,
F f) |
F |
get() |
boolean |
isDisabled() |
boolean |
isEnabled() |
default java.util.Iterator<F> |
iterator() |
default <X> FeatureToggle<X> |
map(java.util.function.Function<? super F,? extends X> map)
Transform this functor using the supplied transformation function
|
static <T> FeatureToggle<T> |
narrow(FeatureToggle<? extends T> toggle)
Narrow covariant type parameter
|
default FeatureToggle<MonadicValue<F>> |
nest() |
default FeatureToggle<F> |
notNull()
Filter elements retaining only values which are not null
|
default <U> FeatureToggle<U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a stream that are of a given type.
|
default java.util.Optional<F> |
optional() |
default <R> FeatureToggle<R> |
patternMatch(java.util.function.Function<Matchable.CheckValue1<F,R>,Matchable.CheckValue1<F,R>> case1,
java.util.function.Supplier<? extends R> otherwise)
Transform the elements of this Stream with a Pattern Matching case and default value
|
default FeatureToggle<F> |
peek(java.util.function.Consumer<? super F> consumer)
Peek at current switch value
|
default ReactiveSeq<F> |
stream() |
default FeatureToggle<F> |
toFeatureToggle() |
default <R> FeatureToggle<R> |
trampoline(java.util.function.Function<? super F,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
default <T> FeatureToggle<T> |
unit(T unit) |
<R> R |
visit(java.util.function.Function<? super F,? extends R> enabled,
java.util.function.Function<? super F,? extends R> disabled)
If this FeatureToggle is enabled the enabled function will be executed
If this FeatureToggle is disabled the disabled function will be executed
|
default <T2,R> FeatureToggle<R> |
zip(java.util.function.BiFunction<? super F,? super T2,? extends R> fn,
org.reactivestreams.Publisher<? extends T2> app)
Equivalent to ap, but accepts a Publisher and takes the first value only from that publisher.
|
default <T2,R> FeatureToggle<R> |
zip(java.lang.Iterable<? extends T2> app,
java.util.function.BiFunction<? super F,? super T2,? extends R> fn)
Equivalent to ap, but accepts an Iterable and takes the first value only from that iterable.
|
default <U> FeatureToggle<org.jooq.lambda.tuple.Tuple2<F,U>> |
zip(java.lang.Iterable<? extends U> other)
Zip (combine) this Zippable with the supplied Iterable combining both into a Tuple2
|
default <U> FeatureToggle<org.jooq.lambda.tuple.Tuple2<F,U>> |
zip(org.jooq.lambda.Seq<? extends U> other)
Zip (combine) this Zippable with the supplied Seq combining both into a Tuple2
|
default <U,R> FeatureToggle<R> |
zip(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiFunction<? super F,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Seq, using the supplied combining function
|
default <U> FeatureToggle<org.jooq.lambda.tuple.Tuple2<F,U>> |
zip(java.util.stream.Stream<? extends U> other)
Zip (combine) this Zippable with the supplied Stream combining both into a Tuple2
|
default <U,R> FeatureToggle<R> |
zip(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super F,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Stream, using the supplied combining function
|
applyFunctions
collect, fold, fold, generate, iterate, mapReduce, mkString, newSubscriber, of, subscribe, test, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFutureStream, toFutureStream, toIor, toLazyImmutable, toList, toListX, toMaybe, toMutable, toPBagX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toTry, toTry, toXor, toXor, unapply
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldable, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleOptional, startsWith, startsWithIterable, toConcurrentLazyCollection, toConcurrentLazyStreamable, toLazyCollection, validate, xMatch
collect, fromSupplier, isPresent, orElse, orElseGet, orElseThrow, toAtomicReference, toCompletableFuture, toCompletableFutureAsync, toCompletableFutureAsync, toFutureW, toFutureWAsync, toFutureWAsync, toOptional, toOptionalAtomicReference, toStream, visit
toOptional, visit
matches
boolean isEnabled()
boolean isDisabled()
static <T> FeatureToggle<T> narrow(FeatureToggle<? extends T> toggle)
toggle
- Eval with covariant type parameterdefault <U> FeatureToggle<U> cast(java.lang.Class<? extends U> type)
Functor
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)default <R> FeatureToggle<R> trampoline(java.util.function.Function<? super F,? extends Trampoline<? extends R>> mapper)
Functor
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
trampoline
in interface Functor<F>
mapper
- TCO Transformation functiondefault <U> FeatureToggle<U> ofType(java.lang.Class<? extends U> type)
Filterable
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
ofType
in interface Filterable<F>
default FeatureToggle<F> filterNot(java.util.function.Predicate<? super F> fn)
Filterable
of(1,2,3).filter(i->i>2);
//[1,2]
filterNot
in interface Filterable<F>
fn
- to filter elements by, retaining matchesdefault FeatureToggle<F> notNull()
Filterable
of(1,2,null,4).nonNull();
//[1,2,4]
notNull
in interface Filterable<F>
default <T> FeatureToggle<T> unit(T unit)
unit
in interface MonadicValue<F>
unit
in interface MonadicValue1<F>
unit
in interface Unit<F>
<R> R visit(java.util.function.Function<? super F,? extends R> enabled, java.util.function.Function<? super F,? extends R> disabled)
enabled
- Function to execute if enableddisabled
- Function to execute if disableddefault <R> FeatureToggle<R> patternMatch(java.util.function.Function<Matchable.CheckValue1<F,R>,Matchable.CheckValue1<F,R>> case1, java.util.function.Supplier<? extends R> otherwise)
Functor
List<String> result = CollectionX.of(1,2,3,4)
.patternMatch(
c->c.valuesWhere(i->"even", (Integer i)->i%2==0 )
)
// CollectionX["odd","even","odd","even"]
patternMatch
in interface Functor<F>
case1
- Function to generate a case (or chain of cases as a single case)otherwise
- Value if supplied case doesn't matchdefault FeatureToggle<F> toFeatureToggle()
toFeatureToggle
in interface Value<F>
AnyMValue<F> anyM()
anyM
in interface MonadicValue<F>
anyM
in interface MonadicValue1<F>
F get()
get
in interface Convertable<F>
get
in interface java.util.function.Supplier<F>
static <F> FeatureToggle.Enabled<F> enable(F f)
f
- switch valuestatic <F> FeatureToggle.Disabled<F> disable(F f)
f
- switch valuestatic <F> FeatureToggle<F> from(FeatureToggle<F> from, F f)
from
- Create a switch with the same typef
- but with this value (f)default FeatureToggle<F> peek(java.util.function.Consumer<? super F> consumer)
default FeatureToggle<MonadicValue<F>> nest()
nest
in interface MonadicValue<F>
default <R> FeatureToggle<R> coflatMap(java.util.function.Function<? super MonadicValue<F>,R> mapper)
coflatMap
in interface MonadicValue<F>
coflatMap
in interface MonadicValue1<F>
default FeatureToggle<F> combineEager(Monoid<F> monoid, MonadicValue<? extends F> v2)
MonadicValue1
Monoid<Integer> add = Monoid.of(1,Semigroups.intSum);
Maybe.of(10).combineEager(add,Maybe.none());
//Maybe[10]
Maybe.none().combineEager(add,Maybe.of(10));
//Maybe[10]
Maybe.none().combineEager(add,Maybe.none());
//Maybe.none()
Maybe.of(10).combineEager(add,Maybe.of(10));
//Maybe[20]
Monoid<Integer> firstNonNull = Monoid.of(null , Semigroups.firstNonNull());
Maybe.of(10).combineEager(firstNonNull,Maybe.of(10));
//Maybe[10]
combineEager
in interface MonadicValue1<F>
default <X> FeatureToggle<X> flatMap(java.util.function.Function<? super F,? extends MonadicValue<? extends X>> flatMapper)
flatMap
in interface MonadicValue1<F>
flatMapper
- Create a new Switch with provided functiondefault <X> FeatureToggle<X> map(java.util.function.Function<? super F,? extends X> map)
Functor
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface ConvertableFunctor<F>
map
in interface Functor<F>
map
in interface MonadicValue<F>
map
in interface MonadicValue1<F>
map
- transform the value inside this Switch into new Switch objectdefault FeatureToggle<F> filter(java.util.function.Predicate<? super F> p)
filter
in interface Filterable<F>
p
- Predicate to test fordefault void forEach(java.util.function.Consumer<? super F> consumer)
forEach
in interface java.lang.Iterable<F>
consumer
- to provide value to.default FeatureToggle.Enabled<F> enable()
default FeatureToggle.Disabled<F> disable()
default FeatureToggle<F> flip()
default java.util.Optional<F> optional()
default ReactiveSeq<F> stream()
default java.util.Iterator<F> iterator()
iterator
in interface Convertable<F>
iterator
in interface java.lang.Iterable<F>
iterator
in interface Matchable.MatchableOptional<F>
iterator
in interface Matchable.ValueAndOptionalMatcher<F>
iterator
in interface Value<F>
default <T2,R> FeatureToggle<R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super F,? super T2,? extends R> fn)
combine
in interface ApplicativeFunctor<F>
app
- fn
- default <T2,R> FeatureToggle<R> zip(java.lang.Iterable<? extends T2> app, java.util.function.BiFunction<? super F,? super T2,? extends R> fn)
default <T2,R> FeatureToggle<R> zip(java.util.function.BiFunction<? super F,? super T2,? extends R> fn, org.reactivestreams.Publisher<? extends T2> app)
default <U,R> FeatureToggle<R> zip(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiFunction<? super F,? super U,? extends R> zipper)
Zippable
default <U,R> FeatureToggle<R> zip(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super F,? super U,? extends R> zipper)
Zippable
default <U> FeatureToggle<org.jooq.lambda.tuple.Tuple2<F,U>> zip(java.util.stream.Stream<? extends U> other)
Zippable
default <U> FeatureToggle<org.jooq.lambda.tuple.Tuple2<F,U>> zip(org.jooq.lambda.Seq<? extends U> other)
Zippable
default <U> FeatureToggle<org.jooq.lambda.tuple.Tuple2<F,U>> zip(java.lang.Iterable<? extends U> other)
Zippable