Class StreamExternalFilter
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.UnaryFunction
com.singularsys.extensions.stream.StreamExternalFilter
- All Implemented Interfaces:
JepComponent,PostfixMathCommandI,Serializable
Filters elements of a stream based on a externally defined predicate.
The predicate can be provided either as a
Predicate
or as a UnaryFunction that returns a boolean value.
For example, to filter out NaN values from a stream of numbers, you could define a function like this:
jep.addFunction("nanfilter",
new ChainableUnaryFunction(
new StreamExternalFilter(
x-> !Double.isNaN(((Number) x).doubleValue()))));
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.singularsys.jep.functions.UnaryFunction
UnaryFunction.FunctionWithException<T> -
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
ConstructorsConstructorDescriptionConstructor using a unary function.StreamExternalFilter(Predicate<Object> filter) Constructor using a predicate. -
Method Summary
Modifier and TypeMethodDescriptionEvaluate the functionGets a light-weight instance suitable for using in multiple threads.voidInitialize the component.Methods inherited from class com.singularsys.jep.functions.UnaryFunction
instanceOf, instanceOf, instanceOf, instanceOf, runMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Constructor Details
-
StreamExternalFilter
Constructor using a predicate.- Parameters:
filter- the predicate used to filter elements
-
StreamExternalFilter
Constructor using a unary function.- Parameters:
fun- a function that returns a boolean value.
-
-
Method Details
-
eval
Description copied from class:UnaryFunctionEvaluate the function- Specified by:
evalin classUnaryFunction- Parameters:
arg- the single argument passed in- Returns:
- the result of the function
- Throws:
EvaluationException- on error
-
init
Description copied from interface:JepComponentInitialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.- Specified by:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-