Package com.isomorphic.criteria
Class Evaluator
java.lang.Object
com.isomorphic.criteria.Evaluator
Helper class for evaluating criteria.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adding custom operator for using in evaluations.boolean
evaluateCriterion
(Map values, Criterion criterion) Evaluating criterion with map of values.static Object
getPathValue
(Map values, String fieldPath) Fetches the value stored at the given dot notation path in the map of values.static String
getPathValueAsString
(Map values, String fieldPath) Fetches the value stored at the given dot notation path in the map of values as a string.static AdvancedCriteria
parseAdvancedCriteria
(Map rawCriteria) Builds anAdvancedCriteria
instance from a structure expressingAdvancedCriteria
as simple Java Collections, that is, nestedMaps
andLists
where aCriterion
is expressed as aMap
containing keys such as "fieldName", "operator", and "value".static Criterion
parseCriterion
(Map rawCriteria) Parse criterion represented as map (usually passed from client-side) into Criterion instance.boolean
valuesMatchCriteria
(Map values, AdvancedCriteria ac) Check values map for matching passed AdvancedCriteria.boolean
valuesMatchCriteria
(Map values, SimpleCriteria sc, String textMatchStyle) Check values map for matching passed Criteria.
-
Method Details
-
addSearchOperator
Adding custom operator for using in evaluations.- Parameters:
op
- - operator to be added.
-
valuesMatchCriteria
public boolean valuesMatchCriteria(Map values, SimpleCriteria sc, String textMatchStyle) throws Exception Check values map for matching passed Criteria.- Parameters:
values
- - map of values to check.sc
- - criteria to check.textMatchStyle
- - style to be used when checking.- Returns:
- true if values match criteria.
- Throws:
Exception
- if an error occurs during criteria evaluation
-
valuesMatchCriteria
Check values map for matching passed AdvancedCriteria.- Parameters:
values
- - map of values to check.ac
- - AdvancedCriteria to check.- Returns:
- true if values match AdvancedCriteria.
- Throws:
Exception
- if an error occurs during criteria evaluation
-
evaluateCriterion
Evaluating criterion with map of values. The method check that passed criterion match passed values.- Parameters:
values
- - map of values to check.criterion
- - criterion to check.- Returns:
- true if values match Criterion.
- Throws:
Exception
- if an error occurs during criterion evaluation
-
parseAdvancedCriteria
Builds anAdvancedCriteria
instance from a structure expressingAdvancedCriteria
as simple Java Collections, that is, nestedMaps
andLists
where aCriterion
is expressed as aMap
containing keys such as "fieldName", "operator", and "value".For all built-in operators (see
DefaultOperators
), instances of the most specificCriterion
class available will be created. Custom operators passed toaddSearchOperator(Operator)
with acriterionClass
specified will create an instance of thatcriterionClass
and apply the key/value pairs found in theMap
specifying the criterion viaDataTools.setProperties(Map, Object)
.For unrecoginized operators, an instance of
CustomCriterion
will be created and populated with values from theMap
specifying theCriterion
.- Parameters:
rawCriteria
- map representation of the criteria to parse- Returns:
- parsed AdvancedCriteria instance
-
parseCriterion
Parse criterion represented as map (usually passed from client-side) into Criterion instance.- Parameters:
rawCriteria
- - criterion represented as map.- Returns:
- parsed criterion.
-
getPathValue
Fetches the value stored at the given dot notation path in the map of values.- Parameters:
values
- the map of values to look through.fieldPath
- the dot notation path to look up.- Returns:
- the value stored at the given path.
-
getPathValueAsString
Fetches the value stored at the given dot notation path in the map of values as a string.- Parameters:
values
- the map of values to look through.fieldPath
- the dot notation path to look up.- Returns:
- the value stored at the given path or empty string if the value was null.
-