T - V - C - public class MappedExtractor<T,V,C> extends Object implements FacadeExtractor<T,V,C>, Mappable<T,V,C>
| Modifier | Constructor and Description |
|---|---|
protected |
MappedExtractor(Extractor<T,V,C> target,
int[] map) |
| 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() |
protected MappedExtractor(Extractor<T,V,C> target, int[] map)
target - Target extractormap - 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.public V extract(C context, Map<C,Map<Extractor<T,? super V,C>,? super V>> cache, T... obj)
Extractorextract in interface Extractor<T,V,C>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.public Set<Integer> parameterIndices()
parameterIndices in interface Extractor<T,V,C>public boolean isContextDependent()
isContextDependent in interface Extractor<T,V,C>public ComparisonResult compareTo(Extractor<T,V,C> other)
Extractorpublic double getCost()
public static <T,V,C> Extractor<T,V,C> mapExtractor(Extractor<T,V,C> target, int[] map)
public Extractor<T,V,C> map(int[] map)
Mappablepublic int[] getMap()