com.isomorphic.criteria

## Class Evaluator

- java.lang.Object
- - com.isomorphic.criteria.Evaluator

-     public class Evaluator
      extends java.lang.Object

  Helper class for evaluating criteria.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSearchOperator(Operator op)` Adding custom operator for using in evaluations.
    `boolean` | `evaluateCriterion(java.util.Map values, Criterion criterion)` Evaluating criterion with map of values.
    `static java.lang.Object` | `getPathValue(java.util.Map values, java.lang.String fieldPath)` Fetches the value stored at the given dot notation path in the map of values.
    `static java.lang.String` | `getPathValueAsString(java.util.Map values, java.lang.String fieldPath)` Fetches the value stored at the given dot notation path in the map of values as a string.
    `static AdvancedCriteria` | `parseAdvancedCriteria(java.util.Map rawCriteria)` Builds an `AdvancedCriteria` instance from a structure expressing `AdvancedCriteria` as simple Java Collections, that is, nested `Maps` and `Lists` where a `Criterion` is expressed as a `Map` containing keys such as "fieldName", "operator", and "value".
    `static Criterion` | `parseCriterion(java.util.Map rawCriteria)` Parse criterion represented as map (usually passed from client-side) into Criterion instance.
    `boolean` | `valuesMatchCriteria(java.util.Map values, AdvancedCriteria ac)` Check values map for matching passed AdvancedCriteria.
    `boolean` | `valuesMatchCriteria(java.util.Map values, SimpleCriteria sc, java.lang.String textMatchStyle)` Check values map for matching passed Criteria.

- - ### Method Detail

    - #### addSearchOperator

          public void addSearchOperator(Operator op)

      Adding custom operator for using in evaluations.
      Parameters:
        `op` - - operator to be added.

    - #### valuesMatchCriteria

          public boolean valuesMatchCriteria(java.util.Map values,
                                             SimpleCriteria sc,
                                             java.lang.String textMatchStyle)
                                      throws java.lang.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:
        `java.lang.Exception`

    - #### valuesMatchCriteria

          public boolean valuesMatchCriteria(java.util.Map values,
                                             AdvancedCriteria ac)
                                      throws java.lang.Exception

      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:
        `java.lang.Exception`

    - #### evaluateCriterion

          public boolean evaluateCriterion(java.util.Map values,
                                           Criterion criterion)
                                    throws java.lang.Exception

      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:
        `java.lang.Exception`

    - #### parseAdvancedCriteria

          public static AdvancedCriteria parseAdvancedCriteria(java.util.Map rawCriteria)

      Builds an `AdvancedCriteria` instance from a structure expressing `AdvancedCriteria` as simple Java Collections, that is, nested `Maps` and `Lists` where a `Criterion` is expressed as a `Map` containing keys such as "fieldName", "operator", and "value".

      For all built-in operators (see `DefaultOperators`), instances of the most specific `Criterion` class available will be created. Custom operators passed to `Evaluator.addSearchOperator(Operator)` with a `criterionClass` specified will create an instance of that `criterionClass` and apply the key/value pairs found in the `Map` specifying the criterion via `DataTools.setProperties(Map, Object)`.

      For unrecoginized operators, an instance of `CustomCriterion` will be created and populated with values from the `Map` specifying the `Criterion`.

    - #### parseCriterion

          public static Criterion parseCriterion(java.util.Map rawCriteria)

      Parse criterion represented as map (usually passed from client-side) into Criterion instance.
      Parameters:
        `rawCriteria` - - criterion represented as map.
      Returns:
        parsed criterion.

    - #### getPathValue

          public static java.lang.Object getPathValue(java.util.Map values,
                                                      java.lang.String fieldPath)

      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

          public static java.lang.String getPathValueAsString(java.util.Map values,
                                                              java.lang.String fieldPath)

      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.