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

LearnLib / learnlib / 19556545386

21 Nov 2025 01:10AM UTC coverage: 94.471%. First build
19556545386

Pull #155

github

web-flow
Merge d1e6e0721 into 7c236fec9
Pull Request #155: Bump Java Version to 17/25

59 of 83 new or added lines in 25 files covered. (71.08%)

12611 of 13349 relevant lines covered (94.47%)

1.73 hits per line

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

64.29
/api/src/main/java/de/learnlib/query/OmegaQuery.java
1
/* Copyright (C) 2013-2025 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.query;
17

18
import java.util.Objects;
19

20
import de.learnlib.sul.ObservableSUL;
21
import net.automatalib.word.Word;
22
import net.automatalib.word.WordBuilder;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24

25
/**
26
 * A query that represents information about infinite words in an ultimately periodic pattern. That is, for two finite
27
 * strings <i>u</i>, <i>v</i>, this class represents the query of the infinite word <i>uv<sup>ω</sup></i>.
28
 * <p>
29
 * When answering OmegaQueries, one needs to specify the periodicity <i>p</i> of the looping suffix <i>v</i>, i.e. for
30
 * what <i>p</i> the answer contains information about the response to the query <i>uv<sup>p</sup></i> which can then
31
 * be generalized to the infinite case since <i>u(v<sup>p</sup>)<sup>ω</sup></i> = <i>uv<sup>ω</sup></i>.
32
 * <p>
33
 * If one cannot determine this value (e.g. because the response exhibits a non-periodic pattern), one may specify a
34
 * negative value for <i>p</i>. {@link #isUltimatelyPeriodic()} then consequently returns {@code false}. In this case
35
 * the output of the query ({@link #getOutput()}) may be undefined.
36
 *
37
 * @param <I>
38
 *         the input type
39
 * @param <D>
40
 *         the output type
41
 *
42
 * @see DefaultQuery
43
 * @see Query
44
 * @see ObservableSUL#getState()
45
 */
46
public class OmegaQuery<I, D> {
47

48
    private final Word<I> prefix;
49
    private final Word<I> loop;
50
    private final int repeat;
51

52
    private @Nullable D output;
53
    private int periodicity;
54

55
    public OmegaQuery(Word<I> prefix, Word<I> loop, int repeat) {
1✔
56
        this.prefix = prefix;
1✔
57
        this.loop = loop;
1✔
58
        this.repeat = repeat;
1✔
59
    }
1✔
60

61
    public void answer(@Nullable D output, int periodicity) {
62
        this.output = output;
1✔
63
        this.periodicity = periodicity;
1✔
64
    }
1✔
65

66
    public Word<I> getPrefix() {
67
        return prefix;
1✔
68
    }
69

70
    public Word<I> getLoop() {
71
        return loop;
1✔
72
    }
73

74
    public int getRepeat() {
75
        return repeat;
1✔
76
    }
77

78
    public @Nullable D getOutput() {
79
        return output;
1✔
80
    }
81

82
    public int getPeriodicity() {
83
        return periodicity;
1✔
84
    }
85

86
    public boolean isUltimatelyPeriodic() {
87
        return periodicity > 0;
1✔
88
    }
89

90
    public DefaultQuery<I, @Nullable D> asDefaultQuery() {
91
        final WordBuilder<I> wb = new WordBuilder<>(prefix.length() + loop.length() * periodicity);
1✔
92
        wb.append(prefix);
1✔
93
        wb.repeatAppend(periodicity, loop);
1✔
94
        return new DefaultQuery<>(wb.toWord(), output);
1✔
95
    }
96

97
    @Override
98
    public String toString() {
99
        return "OmegaQuery{" + "prefix=" + prefix + ", loop=" + loop + ", repeat=" + repeat + ", output=" + output +
×
100
               ", periodicity=" + periodicity + '}';
101
    }
102

103
    @Override
104
    public final boolean equals(@Nullable Object o) {
NEW
105
        return this == o || o instanceof OmegaQuery<?, ?> that && periodicity == that.periodicity &&
×
NEW
106
                            Objects.equals(prefix, that.prefix) && Objects.equals(loop, that.loop) &&
×
NEW
107
                            Objects.equals(output, that.output);
×
108
    }
109

110
    @Override
111
    public final int hashCode() {
112
        int result = 1;
×
113
        result = 31 * result + Objects.hashCode(prefix);
×
114
        result = 31 * result + Objects.hashCode(loop);
×
115
        result = 31 * result + Objects.hashCode(output);
×
116
        result = 31 * result + Integer.hashCode(periodicity);
×
117
        return result;
×
118
    }
119
}
120

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

© 2026 Coveralls, Inc