• 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/TransitionSystem.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;
17

18
import java.util.Collection;
19
import java.util.Collections;
20
import java.util.HashSet;
21
import java.util.Set;
22

23
import net.automatalib.common.util.HashUtil;
24
import net.automatalib.ts.powerset.PowersetView;
25
import net.automatalib.ts.simple.SimpleTS;
26

27
/**
28
 * Transition system interface. This interface extends {@link SimpleTS} by introducing the concept of inspectable
29
 * <i>transitions</i>, allowing to associate other information apart from the successor state with each transition.
30
 *
31
 * @param <S>
32
 *         state class
33
 * @param <I>
34
 *         input symbol class
35
 * @param <T>
36
 *         transition class
37
 */
38
public interface TransitionSystem<S, I, T> extends SimpleTS<S, I> {
39

40
    @Override
41
    default Set<S> getSuccessors(S state, I input) {
42
        Collection<T> transitions = getTransitions(state, input);
1✔
43
        if (transitions.isEmpty()) {
1✔
44
            return Collections.emptySet();
1✔
45
        }
46
        Set<S> result = new HashSet<>(HashUtil.capacity(transitions.size()));
1✔
47
        for (T trans : transitions) {
1✔
48
            result.add(getSuccessor(trans));
1✔
49
        }
1✔
50
        return result;
1✔
51
    }
52

53
    /**
54
     * Retrieves the transitions that can be triggered by the given input symbol.
55
     * <p>
56
     * The return value must not be {@code null}; if there are no transitions triggered by the specified input, {@link
57
     * Collections#emptySet()} should be returned.
58
     *
59
     * @param state
60
     *         the source state.
61
     * @param input
62
     *         the input symbol.
63
     *
64
     * @return the transitions triggered by the given input
65
     */
66
    Collection<T> getTransitions(S state, I input);
67

68
    /**
69
     * Retrieves the successor state of a given transition.
70
     *
71
     * @param transition
72
     *         the transition.
73
     *
74
     * @return the successor state.
75
     */
76
    S getSuccessor(T transition);
77

78
    /**
79
     * Returns a powerset view of this transition system. A powerset view is a deterministic view on a (potentially)
80
     * non-deterministic transition system.
81
     *
82
     * @return a powerset view of this transition system.
83
     */
84
    default PowersetViewTS<?, I, ?, S, T> powersetView() {
85
        return new PowersetView<>(this);
×
86
    }
87
}
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