    001package com.hammurapi.extract;
    002
    003import java.util.concurrent.TimeUnit;
    004
    005/**
    006 * Base class for composite extractors like +, *, / operations.
    007 * @author Pavel Vlasov.
    008 *
    009 * @param <T>
    010 * @param <V>
    011 */
    012public abstract class CompositeExtractorBase<T, V, C> extends ExtractorBase<T, V, C> {
    013
    014        protected Extractor<T, V, C>[] operands;
    015
    016        public CompositeExtractorBase(double initialCost, TimeUnit costUnit, Extractor<T, V, C>... operands) {
    017                super(initialCost, costUnit);
    018                this.operands = operands;
    019        }
    020
    021        @Override
    022        public double getCost() {
    023                if (cost==-1 && costUnit==null) {
    024                        double ret = 0;
    025                        for (Extractor<T,V,C> e : operands) {
    026                                ret+=e.getCost();
    027                        }
    028                        return ret;
    029                }
    030                return super.getCost();
    031        }
    032
    033}