com.hammurapi.extract

## Class MappedExtractor<T,V,C>

- java.lang.Object
- - com.hammurapi.extract.MappedExtractor<T,V,C>

- Type Parameters:
    `T` -
    `V` -
    `C` -
  All Implemented Interfaces:
    Extractor<T,V,C>, FacadeExtractor<T,V,C>, Mappable<T,V,C>
  Direct Known Subclasses:
    MappedPredicate

      public class MappedExtractor<T,V,C>
      extends Object
      implements FacadeExtractor<T,V,C>, Mappable<T,V,C>

  Extractor which maps arguments to the target extractor.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `MappedExtractor(Extractor<T,V,C> target, int[] map)`

  - ### 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()`
    `int[]` | `getMap()`
    `Extractor<T,V,C>` | `getTarget()`
    `boolean` | `isContextDependent()`
    `Extractor<T,V,C>` | `map(int[] map)` Applies mapping to extractor.
    `static <T,V,C> Extractor<T,V,C>` | `mapExtractor(Extractor<T,V,C> target, int[] map)`
    `Set<Integer>` | `parameterIndices()`
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### MappedExtractor

          protected MappedExtractor(Extractor<T,V,C> target,
                         int[] map)

      Parameters:
        `target` - Target extractor
        `map` - Index map, e.g. if it is {5, 3} then the first argument of this extractor becomes the sixth argument of the target extractor and the second argument of this extractor becomes the 4th argument of the target extractor.

  - ### Method Detail

    - #### extract

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

      Description copied from interface: `Extractor`
      Extracts value.
      Specified by:
        `extract` in interface `Extractor<T,V,C>`
      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

          public Set<Integer> parameterIndices()

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

    - #### isContextDependent

          public boolean isContextDependent()

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

    - #### compareTo

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

      Description copied from interface: `Extractor`
      Compares two extractors
      Specified by:
        `compareTo` in interface `Extractor<T,V,C>`
      Parameters:
        `other` - Other extractor
      Returns:
        Comparison result.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getCost

          public double getCost()

      Specified by:
        `getCost` in interface `Extractor<T,V,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.

    - #### mapExtractor

          public static <T,V,C> Extractor<T,V,C> mapExtractor(Extractor<T,V,C> target,
                                              int[] map)

    - #### map

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

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

    - #### getTarget

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

    - #### getMap

          public int[] getMap()