@PublicEvolving public abstract class IterativeCondition<T> extends Object implements Function, Serializable
NFA
.
A condition can be a simple filter or a more complex condition that iterates over the
previously accepted elements in the pattern and decides to accept a new element or not based on
some statistic over these elements. In the former case, the condition should extend the SimpleCondition
class. In the later, the condition should extend this class, which gives you
also access to the previously accepted elements through a IterativeCondition.Context
.
An iterative condition that accepts an element if i) its name is middle, and ii) the sum of
the prices of all accepted elements is less than 5
would look like:
{@code private class MyCondition extends IterativeCondition{
Modifier and Type | Class and Description |
---|---|
static interface |
IterativeCondition.Context<T>
The context used when evaluating the
condition . |
Constructor and Description |
---|
IterativeCondition() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
filter(T value,
IterativeCondition.Context<T> ctx)
The filter function that evaluates the predicate.
|
public abstract boolean filter(T value, IterativeCondition.Context<T> ctx) throws Exception
IMPORTANT: The system assumes that the function does not modify the elements on which the predicate is applied. Violating this assumption can lead to incorrect results.
value
- The value to be tested.ctx
- The IterativeCondition.Context
used for the evaluation of the function and provides access to
the already accepted events in the pattern (see IterativeCondition.Context.getEventsForPattern(String)
).true
for values that should be retained, false
for values to be
filtered out.Exception
- This method may throw exceptions. Throwing an exception will cause the
operation to fail and may trigger recovery.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.