    001package com.hammurapi.extract;
    002
    003import java.util.Collections;
    004import java.util.Set;
    005import java.util.TreeSet;
    006import java.util.concurrent.TimeUnit;
    007
    008/**
    009 * Base class for extractors.
    010 * @author Pavel Vlasov
    011 *
    012 * @param <T>
    013 * @param <V>
    014 * @param <C>
    015 */
    016public abstract class AbstractExtractor<T, V, C> extends ExtractorBase<T, V, C> {
    017
    018        private Set<Integer> parameterIndices;
    019        private boolean contextDependent;
    020
    021        public AbstractExtractor(double initialCost, TimeUnit costUnit, boolean contextDependent, int... parameterIndices) {
    022                super(initialCost, costUnit);
    023                Set<Integer> pi = new TreeSet<Integer>();
    024                for (int idx:parameterIndices) {
    025                        pi.add(idx);
    026                }
    027                this.parameterIndices=Collections.unmodifiableSet(pi);
    028                this.contextDependent=contextDependent;
    029        }
    030
    031        @Override
    032        public Set<Integer> parameterIndices() {
    033                return parameterIndices;
    034        }
    035
    036        @Override
    037        public boolean isContextDependent() {
    038                return contextDependent;
    039        }
    040
    041}