com.hammurapi.extract

## Class ComparisonPredicate<T,V,C>

- java.lang.Object
- - com.hammurapi.extract.ExtractorBase<T,Boolean,C>
  - - com.hammurapi.extract.ComparisonPredicate<T,V,C>

- All Implemented Interfaces:
    BinaryExtractor<T,V,C>, Extractor<T,Boolean,C>, Mappable<T,Boolean,C>, Predicate<T,C>
  Direct Known Subclasses:
    Equal, GreaterEqual, GreaterThan, LessEqual, LessThan, NotEqual

      public abstract class ComparisonPredicate<T,V,C>
      extends ExtractorBase<T,Boolean,C>
      implements Predicate<T,C>, Mappable<T,Boolean,C>, BinaryExtractor<T,V,C>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `ComparisonPredicate.PromotionLevel`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Extractor<T,V,C>` | `leftExtractor`
    `protected Set<Integer>` | `parameterIndices`
    `protected Extractor<T,V,C>` | `rightExtractor`

    - ### Fields inherited from class com.hammurapi.extract.ExtractorBase

      `cost, costUnit, initialCost, invocations, nanos, totalCost`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ComparisonPredicate(double initialCost, TimeUnit costUnit, Extractor<T,V,C> leftExtractor, Extractor<T,V,C> rightExtractor)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `compare(double n1, double n2)`
    `protected abstract boolean` | `compare(float n1, float n2)`
    `protected abstract boolean` | `compare(int n1, int n2)`
    `protected abstract boolean` | `compare(long n1, long n2)`
    `protected abstract boolean` | `compare(Object o1, Object o2)`
    `boolean` | `equals(Object obj)`
    `protected Boolean` | `extractInternal(C context, Map<C,Map<Extractor<T,? super Boolean,C>,? super Boolean>> cache, T... obj)`
    `double` | `getCost()`
    `Extractor<T,V,C>` | `getLeftExtractor()`
    `Extractor<T,V,C>` | `getRightExtractor()`
    `int` | `hashCode()`
    `boolean` | `isContextDependent()`
    `Extractor<T,Boolean,C>` | `map(int[] map)` Applies mapping to extractor.
    `protected abstract Extractor<T,Boolean,C>` | `newInstance(Extractor<T,V,C> leftExtractor, Extractor<T,V,C> rightExtractor)`
    `protected boolean` | `operandsAreEqual(ComparisonPredicate<T,V,C> other)`
    `protected boolean` | `operandsAreReverseEqual(ComparisonPredicate<T,V,C> other)`
    `Set<Integer>` | `parameterIndices()`
    `protected ComparisonPredicate.PromotionLevel` | `promote(Number n1, Number n2)`
    `String` | `toString()`

    - ### Methods inherited from class com.hammurapi.extract.ExtractorBase

      `compareTo, createCacheEntry, extract`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.hammurapi.extract.Extractor

      `compareTo, extract`

- - ### Field Detail

    - #### leftExtractor

          protected Extractor<T,V,C> leftExtractor

    - #### rightExtractor

          protected Extractor<T,V,C> rightExtractor

    - #### parameterIndices

          protected Set<Integer> parameterIndices

  - ### Constructor Detail

    - #### ComparisonPredicate

          protected ComparisonPredicate(double initialCost,
                             TimeUnit costUnit,
                             Extractor<T,V,C> leftExtractor,
                             Extractor<T,V,C> rightExtractor)

  - ### Method Detail

    - #### parameterIndices

          public Set<Integer> parameterIndices()

      Specified by:
        `parameterIndices` in interface `Extractor<T,Boolean,C>`
      Returns:
        Indexes of objects which this extractor uses for computations.

    - #### operandsAreEqual

          protected boolean operandsAreEqual(ComparisonPredicate<T,V,C> other)

    - #### operandsAreReverseEqual

          protected boolean operandsAreReverseEqual(ComparisonPredicate<T,V,C> other)

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `ExtractorBase<T,Boolean,C>`

    - #### isContextDependent

          public boolean isContextDependent()

      Specified by:
        `isContextDependent` in interface `Extractor<T,Boolean,C>`
      Returns:
        True if extractor uses context for extraction. False if only object(s) are used.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### extractInternal

          protected Boolean extractInternal(C context,
                                Map<C,Map<Extractor<T,? super Boolean,C>,? super Boolean>> cache,
                                T... obj)

      Specified by:
        `extractInternal` in class `ExtractorBase<T,Boolean,C>`

    - #### compare

          protected abstract boolean compare(Object o1,
                        Object o2)

    - #### compare

          protected abstract boolean compare(int n1,
                        int n2)

    - #### compare

          protected abstract boolean compare(long n1,
                        long n2)

    - #### compare

          protected abstract boolean compare(float n1,
                        float n2)

    - #### compare

          protected abstract boolean compare(double n1,
                        double n2)

    - #### promote

          protected ComparisonPredicate.PromotionLevel promote(Number n1,
                                                   Number n2)

    - #### getCost

          public double getCost()

      Specified by:
        `getCost` in interface `Extractor<T,Boolean,C>`
      Overrides:
        `getCost` in class `ExtractorBase<T,Boolean,C>`
      Returns:
        Extractor evaluation cost. Cost is used for optimization of computation intensive algorithms. E.g. in Store it is used for selection of indices for query operations.

    - #### map

          public Extractor<T,Boolean,C> map(int[] map)

      Description copied from interface: `Mappable`
      Applies mapping to extractor.
      Specified by:
        `map` in interface `Mappable<T,Boolean,C>`
      Returns:
        Extractor with changed mapping or null if mapping is not possible.

    - #### newInstance

          protected abstract Extractor<T,Boolean,C> newInstance(Extractor<T,V,C> leftExtractor,
                                           Extractor<T,V,C> rightExtractor)

    - #### getLeftExtractor

          public Extractor<T,V,C> getLeftExtractor()

      Specified by:
        `getLeftExtractor` in interface `BinaryExtractor<T,V,C>`

    - #### getRightExtractor

          public Extractor<T,V,C> getRightExtractor()

      Specified by:
        `getRightExtractor` in interface `BinaryExtractor<T,V,C>`