001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of LearnLib, http://www.learnlib.de/. 003 * 004 * LearnLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * LearnLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with LearnLib; if not, see 015 * <http://www.gnu.de/documents/lgpl.en.html>. 016 */ 017package de.learnlib.oracles; 018 019import de.learnlib.api.Filter; 020import de.learnlib.api.MembershipOracle; 021import de.learnlib.api.Query; 022import java.util.Collection; 023 024/** 025 * A chain of oracles. 026 * 027 * @author falkhowar 028 */ 029public class FilterChain<I,O> implements MembershipOracle<I, O> { 030 031 private final MembershipOracle<I,O> oracle; 032 033 @SafeVarargs 034 public FilterChain(MembershipOracle<I,O> endpoint, Filter<I,O> ... chain) { 035 if (chain.length < 1) { 036 this.oracle = endpoint; 037 return; 038 } 039 040 this.oracle = chain[0]; 041 for (int i=0;i<chain.length-1;i++) { 042 chain[i].setNext(chain[i+1]); 043 } 044 chain[chain.length-1].setNext(endpoint); 045 } 046 047 @Override 048 public void processQueries(Collection<? extends Query<I, O>> queries) { 049 this.oracle.processQueries(queries); 050 } 051 052}