001/* Copyright (C) 2013 TU Dortmund
002 * This file is part of AutomataLib, http://www.automatalib.net/.
003 * 
004 * AutomataLib 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 * AutomataLib 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 AutomataLib; if not, see
015 * http://www.gnu.de/documents/lgpl.en.html.
016 */
017package net.automatalib.brics;
018
019import java.util.Collection;
020
021import net.automatalib.automata.fsa.NFA;
022import net.automatalib.automata.fsa.abstractimpl.AbstractNFA;
023import dk.brics.automaton.Automaton;
024import dk.brics.automaton.State;
025
026/**
027 * Adapter class for wrapping a Brics automaton as an {@link NFA}.
028 * <p>
029 * This adapter is backed by the Brics automaton, so changes to the {@link Automaton}
030 * are reflected.
031 * <p>
032 * As a DFA can be regarded as a special case of an NFA, using this class on a Brics
033 * {@link Automaton} will always work. However, determining successor states for input
034 * characters might be much less efficient than when using a {@link BricsDFA}.
035 * 
036 * @author Malte Isberner <malte.isberner@gmail.com>
037 *
038 */
039public class BricsNFA extends AbstractBricsAutomaton implements
040                NFA<State, Character> {
041
042        /**
043         * Constructor.
044         * @param automaton the Brics automaton object
045         */
046        public BricsNFA(Automaton automaton) {
047                super(automaton);
048        }
049
050        /*
051         * (non-Javadoc)
052         * @see net.automatalib.ts.acceptors.AcceptorTS#accepts(java.lang.Iterable)
053         */
054        @Override
055        public boolean accepts(Iterable<Character> input) {
056                return AbstractNFA.accepts(this, input);
057        }
058
059        /*
060         * (non-Javadoc)
061         * @see net.automatalib.automata.fsa.NFA#isAccepting(java.util.Collection)
062         */
063        @Override
064        public boolean isAccepting(Collection<? extends State> states) {
065                return AbstractNFA.isAccepting(this, states);
066        }
067
068}