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

LearnLib / learnlib / 6805330902

08 Nov 2023 11:40PM UTC coverage: 93.335% (+0.008%) from 93.327%
6805330902

push

github

mtf90
typo

11736 of 12574 relevant lines covered (93.34%)

1.69 hits per line

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

95.12
/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/TTTTransition.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of LearnLib, http://www.learnlib.de/.
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 de.learnlib.algorithm.ttt.base;
17

18
import de.learnlib.AccessSequenceProvider;
19
import de.learnlib.datastructure.list.IntrusiveListElem;
20
import de.learnlib.datastructure.list.IntrusiveListElemImpl;
21
import net.automatalib.word.Word;
22
import net.automatalib.word.WordBuilder;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24

25
/**
26
 * A transition in a {@link AbstractTTTHypothesis}.
27
 *
28
 * @param <I>
29
 *         input symbol type
30
 */
31
public class TTTTransition<I, D> extends IntrusiveListElemImpl<TTTTransition<I, D>>
2✔
32
        implements AccessSequenceProvider<I> {
33

34
    private final TTTState<I, D> source;
35
    private final I input;
36
    protected IntrusiveListElem<TTTTransition<I, D>> prevIncoming;
37
    // NON-TREE TRANSITION
38
    AbstractBaseDTNode<I, D> nonTreeTarget;
39
    // TREE TRANSITION
40
    private TTTState<I, D> treeTarget;
41

42
    public TTTTransition(TTTState<I, D> source, I input) {
2✔
43
        this.source = source;
2✔
44
        this.input = input;
2✔
45
    }
2✔
46

47
    public TTTState<I, D> getTreeTarget() {
48
        assert isTree();
2✔
49

50
        return treeTarget;
2✔
51
    }
52

53
    public boolean isTree() {
54
        return treeTarget != null;
2✔
55
    }
56

57
    public AbstractBaseDTNode<I, D> getNonTreeTarget() {
58
        assert !isTree();
2✔
59

60
        return nonTreeTarget;
2✔
61
    }
62

63
    void setNonTreeTarget(AbstractBaseDTNode<I, D> nonTreeTarget) {
64
        this.nonTreeTarget = nonTreeTarget;
2✔
65
        nonTreeTarget.getIncoming().insertIncoming(this);
2✔
66
    }
2✔
67

68
    public AbstractBaseDTNode<I, D> getDTTarget() {
69
        if (treeTarget != null) {
2✔
70
            return treeTarget.dtLeaf;
2✔
71
        }
72
        return nonTreeTarget;
2✔
73
    }
74

75
    public TTTState<I, D> getTarget() {
76
        if (treeTarget != null) {
2✔
77
            return treeTarget;
2✔
78
        }
79

80
        assert nonTreeTarget.isLeaf() :
2✔
81
                "transition target is not a leaf, but is a " + (nonTreeTarget.isTemp() ? "temp" : "non-temp") +
×
82
                " node with discr" + nonTreeTarget.getDiscriminator();
×
83
        assert nonTreeTarget.getData() != null;
2✔
84
        return nonTreeTarget.getData();
2✔
85
    }
86

87
    public TTTState<I, D> getSource() {
88
        return source;
2✔
89
    }
90

91
    public I getInput() {
92
        return input;
2✔
93
    }
94

95
    protected @Nullable Object getProperty() {
96
        return null;
2✔
97
    }
98

99
    @Override
100
    public Word<I> getAccessSequence() {
101
        WordBuilder<I> wb = new WordBuilder<>(); // FIXME capacity hint
2✔
102

103
        TTTTransition<I, D> curr = this;
2✔
104

105
        while (curr != null) {
2✔
106
            wb.add(curr.input);
2✔
107
            curr = curr.source.getParentTransition();
2✔
108
        }
109

110
        return wb.reverse().toWord();
2✔
111
    }
112

113
    void makeTree(TTTState<I, D> treeTarget) {
114
        removeFromList();
2✔
115
        this.treeTarget = treeTarget;
2✔
116
        this.nonTreeTarget = null;
2✔
117
    }
2✔
118

119
    void removeFromList() {
120
        if (prevIncoming != null) {
2✔
121
            prevIncoming.setNextElement(next);
2✔
122
        }
123
        if (next != null) {
2✔
124
            next.prevIncoming = prevIncoming;
2✔
125
        }
126
    }
2✔
127
}
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