Package com.fluxtion.ext.streaming.api
Interface Wrapper<T>
- Type Parameters:
T
-
- All Superinterfaces:
Stateful<T>
- All Known Subinterfaces:
FilterWrapper<T>
- All Known Implementing Classes:
AbstractFilterWrapper
,BooleanEitherFilter
,BooleanFilter
,BooleanMatchFilter
,DefaultNumberWrapper
,DefaultNumberWrapper.DefaultDoubleWrapper
,DefaultNumberWrapper.DefaultIntWrapper
,DefaultNumberWrapper.DefaultLongWrapper
,ElseWrapper
,EventMutableNumber
,EventMutableNumber.EventMutableDouble
,EventMutableNumber.EventMutableInt
,EventMutableNumber.EventMutableLong
,GenericWrapper
,IntFilterEventHandler
,MergingWrapper
,NodeWrapper
,SlidingAggregator
,SlidingNumberAggregator
,StringFilterEventHandler
,StringWrapper
,TestFilter
public interface Wrapper<T> extends Stateful<T>
A wrapper class that holds a reference to a node in the SEP. Any node in SEP
can be a source of a stream of values.
Stream operations are provided to filter and map the underlying wrapped type.
- Author:
- Greg Higgins
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.fluxtion.ext.streaming.api.Stateful
Stateful.StatefulNumber<S>
-
Field Summary
Fields Modifier and Type Field Description static java.util.concurrent.atomic.LongAdder
counter
-
Method Summary
Modifier and Type Method Description default <S> Argument<S>
arg()
default <S> Argument<S>
arg(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier)
default WrappedList<T>
collect()
default Wrapper<T>
console(java.lang.String prefix, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,?>... supplier)
dump this node to console, prefixed with the supplied message.Object.toString()
will be invoked on the node instance.default Wrapper<T>
defaultVal(T defaultValue)
Set the default value for this instance.T
event()
The wrapped nodejava.lang.Class<T>
eventClass()
The type of the wrapped nodedefault <S extends T>
FilterWrapper<T>filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<S,java.lang.Boolean> filter)
default <S> FilterWrapper<T>
filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<? extends S,java.lang.Boolean> filter)
default Wrapper<T>
forEach(com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<T> consumer)
Registers aConsumer
to operate on the current node when an event wave is passing through this node.default Wrapper<T>
forEach(com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<T> consumer, java.lang.String consumerId)
default <S> Wrapper<S>
get(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier)
default <K, S extends java.lang.Number, F extends NumericFunctionStateless, R extends java.lang.Number>
GroupBy<R>group(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,K> key, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, java.lang.Class<F> functionClass)
default <S extends java.lang.Number, F extends NumericFunctionStateless, R extends java.lang.Number>
GroupBy<R>group(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, java.lang.Class<F> functionClass)
default Wrapper<T>
id(java.lang.String id)
Set the node id for this node within the generated SEP.default boolean
isValidOnStart()
default <R, S, U> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<? extends U,? extends S,R> mapper, double arg, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier)
default <R, S, U> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<? extends U,? extends S,R> mapper, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier1, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,U> supplier2)
default <R, S, U> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<? extends U,? extends S,R> mapper, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, Argument<U> arg)
default <R, S, U> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<? extends U,? extends S,R> mapper, Argument<U> arg, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier)
default <R, S, U> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<? extends U,S,R> mapper, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,? extends U> supplier, double arg)
default <R extends java.lang.Number, S, U extends T, V extends S>
Wrapper<R>map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<U,S,R> mapper, double arg1)
default <R, S, U> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<U,S,R> mapper, Argument<S> arg1, Argument<U> arg2)
maps a two arguments using a binary function.default <R, S, U extends T, V extends S>
Wrapper<R>map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<U,S,R> mapper, Argument<V> arg1)
Maps a binary function using the wrapped instance as the first argument to the binary function.default <R, S> Wrapper<R>
map(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<? extends S,R> mapper, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier)
Maps a value using the provided mapping function.default <R, S extends T>
Wrapper<R>map(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<S,R> mapper)
Maps a value using the provided mapping function.The input is the wrapped instance inside thisWrapper
.default Wrapper<T>
notiferMerge(java.lang.Object eventNotifier)
Attaches an event notification instance to the current stream node.default Wrapper<T>
notifierOverride(java.lang.Object eventNotifier)
Attaches an event notification instance to the current stream node, overriding the execution path of the current stream.default Wrapper<T>
notifyOnChange(boolean notifyOnChange)
Controls the notification policy of event notification to child nodes for this stream node.default Wrapper<T>
publishAndReset(java.lang.Object notifier)
Publishes the current value to all child dependencies and then resets.default <R extends T>
Wrapper<T>push(com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<R> mapper)
default <R, S extends R>
Wrapper<T>push(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<R> mapper)
pushes a data item from the current node in the stream to any node.The target node will become part of the same execution graph as the source.default void
reset()
default Wrapper<T>
resetAndPublish(java.lang.Object notifier)
Resets the stateful node and publishes the current value by notifying child nodes.default Wrapper<T>
resetNoPublish(java.lang.Object notifier)
Resets the current value without notifying children of a change.default Wrapper<T>
validOnStart(boolean validOnStart)
Set this property to signal the wrapper has a valid value and child nodes do not have to wait for a trigger notification before using the data from this instance.Methods inherited from interface com.fluxtion.ext.streaming.api.Stateful
combine, deduct, setBucketCount
-
Field Details
-
counter
static final java.util.concurrent.atomic.LongAdder counter
-
-
Method Details
-
event
T event()The wrapped node- Returns:
- the wrapped node
-
eventClass
java.lang.Class<T> eventClass()The type of the wrapped node- Returns:
- wrapped node class
-
reset
default void reset() -
arg
-
arg
-
defaultVal
Set the default value for this instance. The default value will be set when any call to reset is made. Having a default value allows an instance to be used by its children before an event has been processed.- Parameters:
defaultValue
- the default value to use- Returns:
-
filter
default <S extends T> FilterWrapper<T> filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<S,java.lang.Boolean> filter) -
filter
default <S> FilterWrapper<T> filter(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<? extends S,java.lang.Boolean> filter) -
get
-
collect
-
group
default <S extends java.lang.Number, F extends NumericFunctionStateless, R extends java.lang.Number> GroupBy<R> group(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, java.lang.Class<F> functionClass) -
group
default <K, S extends java.lang.Number, F extends NumericFunctionStateless, R extends java.lang.Number> GroupBy<R> group(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,K> key, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, java.lang.Class<F> functionClass) -
map
default <R, S extends T> Wrapper<R> map(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<S,R> mapper)Maps a value using the provided mapping function.The input is the wrapped instance inside thisWrapper
.- Type Parameters:
R
- The return type of the mapping functionS
-- Parameters:
mapper
- the mapping function- Returns:
- A wrapped value containing the result of the mapping operation
-
map
default <R, S> Wrapper<R> map(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<? extends S,R> mapper, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier)Maps a value using the provided mapping function. The input is the return value of the supplier function invoked on the wrapped instance.- Type Parameters:
R
- The return type of the mapping functionS
- The input type required by the mapping function- Parameters:
mapper
- the mapping functionsupplier
-- Returns:
- A wrapped value containing the result of the mapping operation
-
map
default <R, S, U> Wrapper<R> map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<U,S,R> mapper, Argument<S> arg1, Argument<U> arg2)maps a two arguments using a binary function.- Type Parameters:
R
-S
-U
-- Parameters:
mapper
-arg1
-arg2
-- Returns:
-
map
default <R, S, U> Wrapper<R> map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<? extends U,? extends S,R> mapper, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier1, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,U> supplier2) -
map
-
map
-
map
-
map
-
map
default <R, S, U extends T, V extends S> Wrapper<R> map(com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction<U,S,R> mapper, Argument<V> arg1)Maps a binary function using the wrapped instance as the first argument to the binary function.- Type Parameters:
R
- The result type of the mapping functionS
- The type of the supplied argumentU
- The input type for first argument to mapping functionV
- The input type for second argument to mapping function- Parameters:
mapper
- The mapping functionarg1
- The second argument of the binary mapping function- Returns:
-
map
-
push
default <R, S extends R> Wrapper<T> push(com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,S> supplier, com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<R> mapper)pushes a data item from the current node in the stream to any node.The target node will become part of the same execution graph as the source.The returned node is the current node in the stream.
- Type Parameters:
R
-S
-- Parameters:
supplier
-mapper
-- Returns:
- the com.fluxtion.ext.declarative.api.Wrapper
-
push
-
forEach
default Wrapper<T> forEach(com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<T> consumer)Registers aConsumer
to operate on the current node when an event wave is passing through this node. The consumer can perform any operation on the node including mutations. This node, possibly mutated, is passed as a reference to child nodes. No new nodes are created in the stream as a side-effect of this processing.- Parameters:
consumer
-Consumer
of this node- Returns:
- The current node
-
forEach
-
console
default Wrapper<T> console(java.lang.String prefix, com.fluxtion.api.partition.LambdaReflection.SerializableFunction<T,?>... supplier)dump this node to console, prefixed with the supplied message.Object.toString()
will be invoked on the node instance.- Parameters:
prefix
- String prefix for the console messagesupplier
-- Returns:
- The current node
-
notiferMerge
Attaches an event notification instance to the current stream node. When the notifier updates all the child nodes of this stream node will be on the execution path and invoked following normal SEP rules. The existing execution path will be unaltered if either the parent wrapped node or the eventNotifier updates then the execution path will progress.- Parameters:
eventNotifier
- external event notifier- Returns:
-
notifierOverride
Attaches an event notification instance to the current stream node, overriding the execution path of the current stream. Only when the notifier updates will the child nodes of this stream node be on the execution path.- Parameters:
eventNotifier
- external event notifier- Returns:
-
publishAndReset
Publishes the current value to all child dependencies and then resets. After all children have processed the trigger a reset is invoked on the wrapped instance. The publish and reset is triggered when the supplied notifier triggers in the execution graph.- Parameters:
notifier
- trigger for publish and reset- Returns:
-
resetNoPublish
Resets the current value without notifying children of a change. The reset is triggered when the supplied notifier triggers in the execution graph.- Parameters:
notifier
- trigger for reset- Returns:
-
resetAndPublish
Resets the stateful node and publishes the current value by notifying child nodes. The reset is before the notification is broadcast. The reset and publish is triggered when the supplied notifier triggers in the execution graph.- Parameters:
notifier
- trigger for reset and publish- Returns:
-
notifyOnChange
Controls the notification policy of event notification to child nodes for this stream node. The default policy is to invoke child nodes when the return of the parent event method is true. NotifyOnChange notifies the child only when the parent node return of the previous cycle is false and this one is true.This can be useful if a single notification of a breach is required and subsequent continued breaches are swallowed, for example this can prevent logging spamming when combined with filters.
- Parameters:
notifyOnChange
- false = notify always. true = notify on change only- Returns:
- The current node
-
validOnStart
Set this property to signal the wrapper has a valid value and child nodes do not have to wait for a trigger notification before using the data from this instance.- Parameters:
validOnStart
-- Returns:
-
isValidOnStart
default boolean isValidOnStart() -
id
Set the node id for this node within the generated SEP. This is the variable name of the node in a Java SEP. The id must be unique for the SEP.- Parameters:
id
- the unique id of the node in the SEP- Returns:
- The current node
-