• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 13138848026

04 Feb 2025 02:53PM UTC coverage: 92.108% (+2.2%) from 89.877%
13138848026

push

github

mtf90
[maven-release-plugin] prepare release automatalib-0.12.0

16609 of 18032 relevant lines covered (92.11%)

1.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/api/src/main/java/net/automatalib/ts/acceptor/DeterministicAcceptorTS.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.ts.acceptor;
17

18
import java.util.Collection;
19
import java.util.Iterator;
20

21
import net.automatalib.automaton.concept.SuffixOutput;
22
import net.automatalib.ts.AcceptorPowersetViewTS;
23
import net.automatalib.ts.DeterministicTransitionSystem;
24
import net.automatalib.ts.UniversalDTS;
25
import net.automatalib.ts.powerset.DeterministicAcceptorPowersetView;
26

27
/**
28
 * A deterministic acceptor transition system.
29
 *
30
 * @see AcceptorTS
31
 * @see DeterministicTransitionSystem
32
 */
33
public interface DeterministicAcceptorTS<S, I>
1✔
34
        extends AcceptorTS<S, I>, UniversalDTS<S, I, S, Boolean, Void>, SuffixOutput<I, Boolean> {
35

36
    @Override
37
    default Boolean computeOutput(Iterable<? extends I> input) {
38
        return accepts(input);
1✔
39
    }
40

41
    @Override
42
    default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
43
        S tgt = getState(prefix);
1✔
44
        if (tgt != null) {
1✔
45
            S succ = getSuccessor(tgt, suffix);
1✔
46
            return succ != null && isAccepting(succ);
1✔
47
        }
48
        return false;
1✔
49
    }
50

51
    @Override
52
    default boolean accepts(Iterable<? extends I> input) {
53
        S state = getState(input);
1✔
54
        return state != null && isAccepting(state);
1✔
55
    }
56

57
    @Override
58
    default boolean isAccepting(Collection<? extends S> states) {
59
        if (states.isEmpty()) {
1✔
60
            return false;
×
61
        }
62
        Iterator<? extends S> stateIt = states.iterator();
1✔
63
        assert stateIt.hasNext();
1✔
64

65
        S firstState = stateIt.next();
1✔
66
        if (stateIt.hasNext()) {
1✔
67
            throw new IllegalArgumentException("Acceptance of state sets is undefined for DFAs");
×
68
        }
69
        return isAccepting(firstState);
1✔
70
    }
71

72
    @Override
73
    default AcceptorPowersetViewTS<?, I, S> powersetView() {
74
        return new DeterministicAcceptorPowersetView<>(this);
1✔
75
    }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc