T - V - public abstract class ExtractorBase<T,V,C> extends Object implements Extractor<T,V,C>
| Modifier and Type | Field and Description |
|---|---|
protected double |
cost |
protected TimeUnit |
costUnit |
protected double |
initialCost |
protected long |
invocations |
protected boolean |
nanos |
protected double |
totalCost |
| Modifier | Constructor and Description |
|---|---|
protected |
ExtractorBase(double initialCost,
TimeUnit costUnit) |
| Modifier and Type | Method and Description |
|---|---|
ComparisonResult |
compareTo(Extractor<T,V,C> other)
Basic comparisons with True and False.
|
protected Map<Extractor<T,? super V,C>,? super V> |
createCacheEntry() |
boolean |
equals(Object obj) |
V |
extract(C context,
Map<C,Map<Extractor<T,? super V,C>,? super V>> cache,
T... obj)
Extracts value.
|
protected abstract V |
extractInternal(C context,
Map<C,Map<Extractor<T,? super V,C>,? super V>> cache,
T... obj) |
double |
getCost() |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisContextDependent, parameterIndicesprotected long invocations
protected double totalCost
protected boolean nanos
protected double cost
protected double initialCost
protected ExtractorBase(double initialCost, TimeUnit costUnit)
initialCost - Initial cost. If positive, this value is added to the calculated cost. If costUnit is null,
then cost is always equal to the initial cost. If negative and time unit is not null, then absolute value is used as first measurement of cost.costUnit - If this argument is not null, then extractor cost is
calculated as average time to execute extractInternal() method in specified time unit.
If time unit is nanoseconds or microseconds, then System.nanoTime() method is used for
measurement, otherwise Systsm.currentTimeMillis() is used.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 double getCost()
public ComparisonResult compareTo(Extractor<T,V,C> other)
protected abstract V extractInternal(C context, Map<C,Map<Extractor<T,? super V,C>,? super V>> cache, T... obj)