package com.hammurapi.extract;

import java.util.concurrent.TimeUnit;

/**
 * Base class for composite extractors like +, *, / operations.
 * @author Pavel Vlasov.
 *
 * @param <T>
 * @param <V>
 */
public abstract class CompositeExtractorBase<T, V, C> extends ExtractorBase<T, V, C> {
		
	protected Extractor<T, V, C>[] operands;

	public CompositeExtractorBase(double initialCost, TimeUnit costUnit, Extractor<T, V, C>... operands) {
		super(initialCost, costUnit);
		this.operands = operands;
	}
	
	@Override
	public double getCost() {
		if (cost==-1 && costUnit==null) {
			double ret = 0;
			for (Extractor<T,V,C> e : operands) {
				ret+=e.getCost();
			}
			return ret;
		}
		return super.getCost();
	}

}
