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.ts.acceptors.abstractimpl; 018 019import java.util.Collection; 020 021import net.automatalib.ts.abstractimpl.AbstractTS; 022import net.automatalib.ts.acceptors.AcceptorTS; 023 024 025public abstract class AbstractAcceptorTS<S, I> extends AbstractTS<S, I, S> implements 026 AcceptorTS<S, I> { 027 028 public static <S,I> boolean accepts(AcceptorTS<S, I> $this, Iterable<I> input) { 029 Collection<S> states = $this.getStates(input); 030 if(states == null) 031 return false; 032 033 for(S state : states) { 034 if($this.isAccepting(state)) 035 return true; 036 } 037 038 return false; 039 } 040 041 042 public static <S,I> Boolean getStateProperty(AcceptorTS<S,I> $this, S state) { 043 return Boolean.valueOf($this.isAccepting(state)); 044 } 045 046 public static <S,I> Void getTransitionProperty(AcceptorTS<S,I> $this, S transition) { 047 return null; 048 } 049 050 /* 051 * (non-Javadoc) 052 * @see de.ls5.ts.acceptors.AcceptorTS#accepts(java.lang.Iterable) 053 */ 054 @Override 055 public boolean accepts(Iterable<I> input) { 056 return accepts(this, input); 057 } 058 059 @Override 060 public Boolean getStateProperty(S state) { 061 return getStateProperty(this, state); 062 } 063 064 @Override 065 public Void getTransitionProperty(S transition) { 066 return getTransitionProperty(this, transition); 067 } 068 069 070 071 072}