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.automata.fsa.abstractimpl; 018 019import net.automatalib.automata.abstractimpl.AbstractDeterministicAutomaton; 020import net.automatalib.automata.fsa.DFA; 021 022public abstract class AbstractDFA<S, I> extends AbstractDeterministicAutomaton<S, I, S> 023 implements DFA<S, I> { 024 025 public static <S,I> boolean accepts(DFA<S, I> $this, Iterable<I> input) { 026 S tgt = $this.getState(input); 027 if(tgt == null) 028 return false; 029 return $this.isAccepting(tgt); 030 } 031 032 033 034 035 /* 036 * (non-Javadoc) 037 * @see de.ls5.ts.acceptors.AcceptorTS#accepts(java.lang.Iterable) 038 */ 039 @Override 040 public boolean accepts(Iterable<I> input) { 041 return accepts(this, input); 042 } 043 044 /* 045 * (non-Javadoc) 046 * @see de.ls5.ts.UniversalTransitionSystem#getStateProperty(java.lang.Object) 047 */ 048 @Override 049 public Boolean getStateProperty(S state) { 050 return AbstractFSA.getStateProperty(this, state); 051 } 052 053 /* 054 * (non-Javadoc) 055 * @see de.ls5.ts.UniversalTransitionSystem#getTransitionProperty(java.lang.Object) 056 */ 057 @Override 058 public Void getTransitionProperty(S transition) { 059 return AbstractFSA.getTransitionProperty(this, transition); 060 } 061 062 /* 063 * (non-Javadoc) 064 * @see de.ls5.ts.TransitionSystem#getSuccessor(java.lang.Object) 065 */ 066 @Override 067 public S getSuccessor(S transition) { 068 return AbstractFSA.getSuccessor(this, transition); 069 } 070 071 /* 072 * (non-Javadoc) 073 * @see de.ls5.automata.features.SODetOutputAutomaton#computeSuffixOutput(java.lang.Iterable, java.lang.Iterable) 074 */ 075 @Override 076 public Boolean computeSuffixOutput(Iterable<I> prefix, Iterable<I> suffix) { 077 return AbstractFSA.computeSuffixOutput(this, prefix, suffix); 078 } 079 080 /* 081 * (non-Javadoc) 082 * @see de.ls5.automata.features.OutputAutomaton#computeOutput(java.lang.Iterable) 083 */ 084 @Override 085 public Boolean computeOutput(Iterable<I> input) { 086 return AbstractFSA.computeOutput(this, input); 087 } 088 089}