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

LearnLib / learnlib / 31619759710

12 Aug 2026 04:27PM UTC coverage: 95.488% (+1.1%) from 94.368%
31619759710

push

github

mtf90
use new version scheme

15533 of 16267 relevant lines covered (95.49%)

1.72 hits per line

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

74.6
/commons/datastructures/src/main/java/de/learnlib/datastructure/pta/AbstractBlueFringePTAState.java
1
/* Copyright (C) 2013-2026 TU Dortmund University
2
 * This file is part of LearnLib <https://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.datastructure.pta;
17

18
import net.automatalib.common.util.comparison.CmpUtil;
19
import org.checkerframework.checker.nullness.qual.Nullable;
20

21
/**
22
 * Note: this class has a natural ordering that is inconsistent with equals.
23
 */
24
@SuppressWarnings("PMD.OverrideBothEqualsAndHashCodeOnComparable")
2✔
25
public abstract class AbstractBlueFringePTAState<S extends AbstractBlueFringePTAState<S, SP, TP>, SP, TP>
2✔
26
        extends AbstractBasePTAState<S, SP, TP> implements Comparable<S> {
27

28
    protected boolean isCopy;
29
    protected Color color = Color.WHITE;
2✔
30
    protected @Nullable S parent;
31
    protected int parentInput = -1;
2✔
32
    protected int @Nullable [] access;
33

34
    public Color getColor() {
35
        return color;
2✔
36
    }
37

38
    @Override
39
    public S copy() {
40
        S copy = super.copy();
2✔
41
        copy.isCopy = true;
2✔
42
        return copy;
2✔
43
    }
44

45
    @Override
46
    @SuppressWarnings("unchecked")
47
    public void setSuccessor(int index, S successor, int alphabetSize) {
48
        super.setSuccessor(index, successor, alphabetSize);
×
49
        successor.parent = (S) this;
×
50
        successor.parentInput = index;
×
51
    }
×
52

53
    @Override
54
    @SuppressWarnings("unchecked")
55
    protected S createSuccessor(int index) {
56
        S state = super.createSuccessor(index);
2✔
57
        state.parent = (S) this;
2✔
58
        state.parentInput = index;
2✔
59
        return state;
2✔
60
    }
61

62
    public PTATransition<S> makeBlue() {
63
        if (!isWhite()) {
2✔
64
            throw new IllegalStateException();
×
65
        }
66
        assert parent != null;
2✔
67
        if (!parent.isRed()) {
2✔
68
            throw new IllegalStateException();
×
69
        }
70

71
        this.color = Color.BLUE;
2✔
72

73
        return new PTATransition<>(parent, parentInput);
2✔
74
    }
75

76
    public boolean isWhite() {
77
        return color == Color.WHITE;
2✔
78
    }
79

80
    public boolean isRed() {
81
        return color == Color.RED;
2✔
82
    }
83

84
    public void makeRed(int id) {
85
        this.color = Color.RED;
2✔
86
        this.id = id;
2✔
87
        buildAccess();
2✔
88
    }
2✔
89

90
    private void buildAccess() {
91
        if (access != null) {
2✔
92
            throw new IllegalStateException();
×
93
        }
94
        if (parent == null) {
2✔
95
            this.access = new int[0];
2✔
96
            return;
2✔
97
        }
98
        int[] parentAccess = parent.access;
2✔
99
        if (parentAccess == null) {
2✔
100
            throw new IllegalStateException();
×
101
        }
102
        int paLen = parentAccess.length;
2✔
103
        this.access = new int[paLen + 1];
2✔
104
        System.arraycopy(parentAccess, 0, this.access, 0, paLen);
2✔
105
        this.access[paLen] = parentInput;
2✔
106
    }
2✔
107

108
    public boolean isBlue() {
109
        return color == Color.BLUE;
2✔
110
    }
111

112
    @Override
113
    public int compareTo(S other) {
114
        if (this == other) {
1✔
115
            return 0;
1✔
116
        }
117
        if (access == null) {
1✔
118
            if (other.access == null) {
×
119
                return 0;
×
120
            }
121
            return 1;
×
122
        }
123
        if (other.access == null) {
1✔
124
            return -1;
×
125
        }
126

127
        return CmpUtil.canonicalCompare(access, other.access);
1✔
128
    }
129

130
    public int lexCompareTo(S other) {
131
        if (this == other) {
1✔
132
            return 0;
1✔
133
        }
134
        if (access == null) {
1✔
135
            if (other.access == null) {
×
136
                return 0;
×
137
            }
138
            return 1;
×
139
        }
140
        if (other.access == null) {
1✔
141
            return -1;
×
142
        }
143

144
        return CmpUtil.lexCompare(access, other.access);
1✔
145
    }
146

147
    public void setForeignSuccessor(int index, S successor, int alphabetSize) {
148
        super.setSuccessor(index, successor, alphabetSize);
1✔
149
    }
1✔
150

151
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc