com.hammurapi.extract

## Interface Extractor<T,V,C>

- Type Parameters:
    `T` - Object type.
    `V` - Value type.
    `C` - Context type.
  All Known Subinterfaces:
    CommutativeCompositePredicate<T,C,S>, CompositePredicate<T,PC,C,S>, FacadeExtractor<T,V,C>, Predicate<T,C>
  All Known Implementing Classes:
    AbstractExtractor, AbstractPredicate, Add, And, CommutativeAnd, CommutativeOr, ComparisonPredicate, CompiledExtractorBase, CompositeExtractorBase, Constant, Divide, Equal, ExtractorBase, False, GreaterEqual, GreaterThan, IndexedExtractor, InstanceOfPredicate, LessEqual, LessThan, MappedExtractor, MappedPredicate, MethodExtractor, Multiply, Not, NotEqual, Or, ScriptingPredicate, Subtract, TimeIntervalPredicate, True

      public interface Extractor<T,V,C>

  Extractors extract values from objects. Extractors are used to reduce number of calcluations performed on objects through caching of extracted values. Extractors shall implement equals() and hashCode(). Two extractors which extract the same value from the same objects shall be equal.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ComparisonResult` | `compareTo(Extractor<T,V,C> other)` Compares two extractors
    `V` | `extract(C context, Map<C,Map<Extractor<T,? super V,C>,? super V>> cache, T... obj)` Extracts value.
    `double` | `getCost()`
    `boolean` | `isContextDependent()`
    `Set<Integer>` | `parameterIndices()`

- - ### Method Detail

    - #### extract

          V extract(C context,
                  Map<C,Map<Extractor<T,? super V,C>,? super V>> cache,
                  T... obj)

      Extracts value.
      Parameters:
        `context` - Extraction context. Extraction context may provide source for constants for comparison with object values.
        `cache` - Cache of values extracted from the source object for the given context. Composite extractors can use cache to find already extracted values and to store extracted values. For example extractor which extracts object area as obj.getWidth()*obj.getHeight() may find that width was already extracted and getWidth() doesn't have to be invoked. So it invokes getHeight() and stores returned value to the cache. It also calculates object area and stores it to the cache. A particular cache instance is valid only for a particular obj array, i.e. it can be re-used between extractors but not between arguments.
        `obj` - Source objects.
      Returns:
        Extracted value.

    - #### parameterIndices

          Set<Integer> parameterIndices()

      Returns:
        Indexes of objects which this extractor uses for computations.

    - #### isContextDependent

          boolean isContextDependent()

      Returns:
        True if extractor uses context for extraction. False if only object(s) are used.

    - #### compareTo

          ComparisonResult compareTo(Extractor<T,V,C> other)

      Compares two extractors
      Parameters:
        `other` - Other extractor
      Returns:
        Comparison result.

    - #### getCost

          double getCost()

      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.