Class StreamFunctionCompiler<T,F>
java.lang.Object
com.fluxtion.ext.streaming.builder.stream.StreamFunctionCompiler<T,F>
- Type Parameters:
T
- The test function applied to the filter subjectF
- The filter subject under test
public class StreamFunctionCompiler<T,F>
extends java.lang.Object
Applies filtering logic to a node in the execution graph. The filter invokes
a predicate that tests a node for a valid match. The outcome of the match has
the following effect:
- Successful match allows the event wave to propagate.
- Failed match the event wave stops at the node under test.
Filtering has the following characteristics:
- Filter functions are either instance or static methods.
- An instance filter is a node in the SEP and can receive inputs from any other nodes.
- An instance filter is stateful, the same filter instance will be used across multiple event processing cycles.
- An instance filter can attach to any SEP life-cycle method such as
AfterEvent
- A filter inspection target can be a method reference or a node in the execution graph.
- A ,target method reference can return either a primitive or reference types.
- Fluxtion will cast all supplied values to the receiving type.
- Lambdas cannot be used as filter predicates use method references.
@SepBuilder(name="FilterTest", packageName="com.fluxtion.testfilter")
public void buildFilter(SEPConfig cfg) {
MyDataHandler dh1 = cfg.addNode(new MyDataHandler("dh1"));
filter(lt(34), dh1::getDoubleVal).build();
filter(positive(), dh1::getIntVal).build();
}
...
public class NumericValidator {
//method reference wraps instance test
public static SerializableFunction lt(int test) {
return (SerializableFunction)new NumericValidator(test)::lessThan;
}
//method reference wraps static test
public static SerializableFunction positive() {
return (SerializableFunction) NumericValidator::positiveInt;
}
public int limit;
public NumericValidator(int limit) { this.limit = limit; }
public static boolean positiveInt(int d) { return d > 0; }
public boolean greaterThan(int d) { return d > limit; }
public boolean lessThan(int d) { return d < limit; } }
- Author:
- V12 Technology Ltd.
-
Method Summary
Modifier and Type Method Description com.fluxtion.ext.streaming.api.Wrapper<F>
build()
static <S, C> StreamFunctionCompiler
consume(C consumer, java.lang.reflect.Method mappingMethod, S source)
static <T, R extends java.lang.Boolean>
StreamFunctionCompilerfilter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,R> filter, com.fluxtion.api.partition.LambdaReflection.SerializableSupplier<T> supplier)
static <T, R extends java.lang.Boolean, S>
StreamFunctionCompilerfilter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,R> filter, S source)
static <T, R extends java.lang.Boolean, S>
StreamFunctionCompilerfilter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,R> filter, S source, java.lang.reflect.Method accessor)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilerfilter(F filter, java.lang.reflect.Method filterMethod, S source)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilerfilter(F filter, java.lang.reflect.Method filterMethod, S source, java.lang.reflect.Method accessor)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilerfilter(F filter, java.lang.reflect.Method filterMethod, S source, java.lang.reflect.Method accessor, boolean cast)
instance filter generation methodstatic <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilerfilter(java.lang.reflect.Method filterMethod, S source)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilerfilter(java.lang.reflect.Method filterMethod, S source, java.lang.reflect.Method accessor, boolean cast)
static filter generation methodstatic <S> com.fluxtion.ext.streaming.api.Wrapper<S>
get(com.fluxtion.api.partition.LambdaReflection.SerializableSupplier<S> source)
static <S> com.fluxtion.ext.streaming.api.Wrapper
get(java.lang.reflect.Method accessor, S source)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilermap(F mapper, java.lang.reflect.Method mappingMethod, com.fluxtion.ext.streaming.api.stream.Argument... args)
Build a mapping function from n-ary argumentsstatic <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilermap(F mapper, java.lang.reflect.Method mappingMethod, S source, java.lang.reflect.Method accessor, boolean cast)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilermapSet(F mapper, java.lang.reflect.Method mappingMethod, com.fluxtion.ext.streaming.api.stream.Argument... args)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilerpush(F mapper, java.lang.reflect.Method mappingMethod, S source, java.lang.reflect.Method accessor, boolean cast)
static <T, R extends java.lang.Boolean, S, F>
StreamFunctionCompilertest(F mapper, java.lang.reflect.Method mappingMethod, com.fluxtion.ext.streaming.api.stream.Argument... args)
Build aTest
from n-ary arguments
-
Method Details
-
filter
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler filter(java.lang.reflect.Method filterMethod, S source, java.lang.reflect.Method accessor, boolean cast)static filter generation method- Type Parameters:
T
-R
-S
-F
-- Parameters:
filterMethod
-source
-accessor
-cast
-- Returns:
-
mapSet
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler mapSet(F mapper, java.lang.reflect.Method mappingMethod, com.fluxtion.ext.streaming.api.stream.Argument... args) -
test
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler test(F mapper, java.lang.reflect.Method mappingMethod, com.fluxtion.ext.streaming.api.stream.Argument... args)Build aTest
from n-ary arguments- Type Parameters:
T
-R
-S
-F
-- Parameters:
mapper
-mappingMethod
-args
-- Returns:
-
map
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler map(F mapper, java.lang.reflect.Method mappingMethod, com.fluxtion.ext.streaming.api.stream.Argument... args)Build a mapping function from n-ary arguments- Type Parameters:
T
-R
-S
-F
-- Parameters:
mapper
-mappingMethod
-args
-- Returns:
-
map
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler map(F mapper, java.lang.reflect.Method mappingMethod, S source, java.lang.reflect.Method accessor, boolean cast) -
push
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler push(F mapper, java.lang.reflect.Method mappingMethod, S source, java.lang.reflect.Method accessor, boolean cast) -
get
public static <S> com.fluxtion.ext.streaming.api.Wrapper<S> get(com.fluxtion.api.partition.LambdaReflection.SerializableSupplier<S> source) -
get
public static <S> com.fluxtion.ext.streaming.api.Wrapper get(java.lang.reflect.Method accessor, S source) -
consume
public static <S, C> StreamFunctionCompiler consume(C consumer, java.lang.reflect.Method mappingMethod, S source) -
filter
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler filter(F filter, java.lang.reflect.Method filterMethod, S source, java.lang.reflect.Method accessor, boolean cast)instance filter generation method- Type Parameters:
T
-R
-S
-F
-- Parameters:
filter
-filterMethod
-source
-accessor
-cast
-- Returns:
-
filter
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler filter(F filter, java.lang.reflect.Method filterMethod, S source, java.lang.reflect.Method accessor) -
filter
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler filter(F filter, java.lang.reflect.Method filterMethod, S source) -
filter
public static <T, R extends java.lang.Boolean, S, F> StreamFunctionCompiler filter(java.lang.reflect.Method filterMethod, S source) -
filter
public static <T, R extends java.lang.Boolean, S> StreamFunctionCompiler filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,R> filter, S source, java.lang.reflect.Method accessor) -
filter
public static <T, R extends java.lang.Boolean, S> StreamFunctionCompiler filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,R> filter, S source) -
filter
public static <T, R extends java.lang.Boolean> StreamFunctionCompiler filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,R> filter, com.fluxtion.api.partition.LambdaReflection.SerializableSupplier<T> supplier) -
build
-