public class ContainsPredicate extends Predicate
ContainsPredicate is a predicate implementation testing whether a string value exists
within some set of strings.
It it expected that the data supplied to the evaluate(Object) method is as Set
of Strings retrieved from a context (a Map of keys to values, where each value
can be an explicit value or a Map of values creating a tree structure.
| Modifier and Type | Field and Description |
|---|---|
static String |
NAME
The name of this
Predicate implementation |
| Constructor and Description |
|---|
ContainsPredicate(ContextTransformer transformer,
String value)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
boolean |
evaluate(Object o) |
protected boolean |
evaluateTransformedData(Object data)
Abstract method used internally to process the
evaluate(Object) logic after the
input data is transformed. |
static ContainsPredicate |
fromMap(Map<String,Object> map)
Creates a new
ContainsPredicate using the given Map of data. |
String |
getContextKey()
Gets the context key assigned to the
ContextTransformer. |
ContextTransformer |
getTransformer()
Gets the
Transformer |
String |
getValue()
Gets the test value
|
int |
hashCode() |
void |
setTransformer(ContextTransformer transformer)
Sets the
Transformer |
Map<String,Object> |
toMap()
|
public static final String NAME
Predicate implementationpublic ContainsPredicate(ContextTransformer transformer, String value)
transformer - the ContextTransformer configured with the context key to findvalue - the value to testpublic static ContainsPredicate fromMap(Map<String,Object> map)
ContainsPredicate using the given Map of data.
It is expected that the map contains a single Map.Entry where the key name
is "contains" and the value is a Collection of 2 Strings. The first value
should be the key to use when retrieving data from the context, which should resolve to a
Set of Strings (or null). The second value should be the value to check for
existing in the relevant set.
ContainsPredicatepublic String getValue()
protected boolean evaluateTransformedData(Object data)
evaluate(Object) logic after the
input data is transformed.data - the transformed data to usetrue, false)Predicate.evaluate(Object)public int hashCode()
public boolean equals(Object obj)
public ContextTransformer getTransformer()
TransformerContextTransformerpublic void setTransformer(ContextTransformer transformer)
Transformertransformer - a ContextTransformerpublic String getContextKey()
ContextTransformer.
This key is used to identify which value from the context a passed to the
Predicate.evaluate(Object) method
public boolean evaluate(Object o)
Copyright © 2022 Apache Software Foundation. All rights reserved.