3030import net .automatalib .ts .simple .SimpleDTS ;
3131import net .automatalib .word .Word ;
3232import net .automatalib .word .WordBuilder ;
33- import org .checkerframework .checker .nullness .qual .NonNull ;
3433import org .checkerframework .checker .nullness .qual .Nullable ;
3534
3635public abstract class AbstractLasso <I , D > implements Lasso <I , D > {
@@ -62,13 +61,12 @@ public abstract class AbstractLasso<I, D> implements Lasso<I, D> {
6261 public <S > AbstractLasso (DetOutputAutomaton <S , I , ?, D > automaton ,
6362 Collection <? extends I > inputs ,
6463 int unfoldTimes ) {
65- this (validateLassoShape (automaton , inputs , unfoldTimes ), automaton , inputs , unfoldTimes );
64+ this (automaton , validateLassoShape (automaton , inputs , unfoldTimes ), inputs , unfoldTimes );
6665 }
6766
6867 // utility constructor to prevent finalizer attacks, see SEI CERT Rule OBJ-11
69- @ SuppressWarnings ("PMD.UnusedFormalParameter" )
70- private <S > AbstractLasso (boolean valid ,
71- DetOutputAutomaton <S , I , ?, D > automaton ,
68+ private <S > AbstractLasso (DetOutputAutomaton <S , I , ?, D > automaton ,
69+ S init ,
7270 Collection <? extends I > inputs ,
7371 int unfoldTimes ) {
7472 // save the original automaton
@@ -86,8 +84,7 @@ private <S> AbstractLasso(boolean valid,
8684 final WordBuilder <I > wb = new WordBuilder <>();
8785
8886 // start visiting the initial state
89- @ SuppressWarnings ("nullness" ) // we have checked non-nullness of the initial state
90- @ NonNull S current = automaton .getInitialState ();
87+ S current = init ;
9188
9289 // index for the current state
9390 int i = 0 ;
@@ -212,14 +209,15 @@ public Alphabet<I> getInputAlphabet() {
212209 return getSuccessor (state , input );
213210 }
214211
215- private static <S , I , D > boolean validateLassoShape (DetOutputAutomaton <S , I , ?, D > automaton ,
216- Collection <? extends I > inputs ,
217- int unfoldTimes ) {
212+ private static <S , I , D > S validateLassoShape (DetOutputAutomaton <S , I , ?, D > automaton ,
213+ Collection <? extends I > inputs ,
214+ int unfoldTimes ) {
218215 if (unfoldTimes <= 0 ) {
219216 throw new AssertionError ();
220217 }
221218
222- if (automaton .getInitialState () == null ) {
219+ final S init = automaton .getInitialState ();
220+ if (init == null ) {
223221 throw new IllegalArgumentException (NO_LASSO );
224222 }
225223
@@ -233,6 +231,6 @@ private static <S, I, D> boolean validateLassoShape(DetOutputAutomaton<S, I, ?,
233231 throw new IllegalArgumentException (NO_LASSO );
234232 }
235233
236- return true ;
234+ return init ;
237235 }
238236}
0 commit comments