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.AbstractAutomaton;
020import net.automatalib.automata.fsa.FiniteStateAcceptor;
021import net.automatalib.commons.util.collections.IterableUtil;
022
023
024public abstract class AbstractFSA<S, I> extends AbstractAutomaton<S,I,S> implements FiniteStateAcceptor<S, I> {
025        
026        public static <S,I> Boolean getStateProperty(FiniteStateAcceptor<S,I> $this, S state) {
027                return Boolean.valueOf($this.isAccepting(state));
028        }
029        
030        public static <S,I> Void getTransitionProperty(FiniteStateAcceptor<S,I> $this, S transition) {
031                return null;
032        }
033        
034        public static <S,I> S getSuccessor(FiniteStateAcceptor<S,I> $this, S transition) {
035                return transition;
036        }
037
038        
039        public static <S,I> Boolean computeOutput(FiniteStateAcceptor<S,I> $this, Iterable<I> input) {
040                return $this.accepts(input);
041        }
042        
043        public static <S,I> Boolean computeSuffixOutput(FiniteStateAcceptor<S,I> $this, Iterable<I> prefix, Iterable<I> suffix) {
044                Iterable<I> input = IterableUtil.concat(prefix, suffix);
045                return $this.computeOutput(input);
046        }
047        
048        @Override
049        public Boolean getStateProperty(S state) {
050                return getStateProperty(this, state);
051        }
052        
053        @Override
054        public Void getTransitionProperty(S transition) {
055                return getTransitionProperty(this, transition);
056        }
057        
058        @Override
059        public S getSuccessor(S transition) {
060                return getSuccessor(this, transition);
061        }
062        
063        @Override
064        public Boolean computeOutput(Iterable<I> input) {
065                return computeOutput(this, input);
066        }
067        
068        @Override
069        public Boolean computeSuffixOutput(Iterable<I> prefix, Iterable<I> suffix) {
070                return computeSuffixOutput(this, prefix, suffix);
071        }
072        
073}