001package de.learnlib.eqtests.basic;
002
003import java.util.ArrayList;
004import java.util.Arrays;
005import java.util.Collection;
006import java.util.List;
007
008import de.learnlib.api.EquivalenceOracle;
009import de.learnlib.oracles.DefaultQuery;
010
011public class EQOracleChain<A, I, O> implements EquivalenceOracle<A, I, O> {
012        
013        private final List<EquivalenceOracle<? super A, I, O>> oracles;
014
015        public EQOracleChain(List<? extends EquivalenceOracle<? super A,I,O>> oracles) {
016                this.oracles = new ArrayList<>(oracles);
017        }
018        
019        @SafeVarargs
020        public EQOracleChain(EquivalenceOracle<? super A,I,O> ...oracles) {
021                this(Arrays.asList(oracles));
022        }
023
024        /*
025         * (non-Javadoc)
026         * @see de.learnlib.api.EquivalenceOracle#findCounterExample(java.lang.Object, java.util.Collection)
027         */
028        @Override
029        public DefaultQuery<I, O> findCounterExample(A hypothesis,
030                        Collection<? extends I> inputs) {
031                for(EquivalenceOracle<? super A,I,O> eqOracle : oracles) {
032                        DefaultQuery<I,O> ceQry = eqOracle.findCounterExample(hypothesis, inputs);
033                        if(ceQry != null)
034                                return ceQry;
035                }
036                return null;
037        }
038
039}