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

LearnLib / learnlib / 6433387082

06 Oct 2023 03:10PM UTC coverage: 92.296% (-0.007%) from 92.303%
6433387082

push

github

mtf90
update Falk's developer id

11573 of 12539 relevant lines covered (92.3%)

1.67 hits per line

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

94.12
/commons/util/src/main/java/de/learnlib/util/mealy/SymbolOracleWrapper.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.util.mealy;
17

18
import java.util.ArrayList;
19
import java.util.Collection;
20
import java.util.List;
21

22
import de.learnlib.api.oracle.MembershipOracle;
23
import de.learnlib.api.query.Query;
24
import net.automatalib.words.Word;
25
import org.checkerframework.checker.nullness.qual.Nullable;
26

27
/**
28
 * Word-to-Symbol-Oracle adapter.
29
 * <p>
30
 * Wraps an oracle which uses {@link Word}s as its output to an oracle which only yields the last symbol of each
31
 * output.
32
 *
33
 * @param <I>
34
 *         input symbol type
35
 * @param <O>
36
 *         output symbol type
37
 */
38
final class SymbolOracleWrapper<I, O> implements MembershipOracle<I, @Nullable O> {
39

40
    private final MembershipOracle<I, Word<O>> wordOracle;
41

42
    /**
43
     * Constructor.
44
     *
45
     * @param wordOracle
46
     *         the {@link MembershipOracle} returning output words.
47
     */
48
    SymbolOracleWrapper(MembershipOracle<I, Word<O>> wordOracle) {
1✔
49
        this.wordOracle = wordOracle;
1✔
50
    }
1✔
51

52
    @Override
53
    public void processQueries(Collection<? extends Query<I, @Nullable O>> queries) {
54
        List<LastSymbolQuery<I, O>> lsQueries = new ArrayList<>(queries.size());
1✔
55
        for (Query<I, @Nullable O> qry : queries) {
1✔
56
            lsQueries.add(new LastSymbolQuery<>(qry));
1✔
57
        }
1✔
58

59
        wordOracle.processQueries(lsQueries);
1✔
60
    }
1✔
61

62
    private static final class LastSymbolQuery<I, O> extends Query<I, Word<O>> {
63

64
        private final Query<I, @Nullable O> originalQuery;
65

66
        LastSymbolQuery(Query<I, @Nullable O> originalQuery) {
1✔
67
            this.originalQuery = originalQuery;
1✔
68
        }
1✔
69

70
        @Override
71
        public void answer(Word<O> output) {
72
            originalQuery.answer(output.isEmpty() ? null : output.lastSymbol());
1✔
73
        }
1✔
74

75
        @Override
76
        public Word<I> getPrefix() {
77
            return originalQuery.getPrefix();
1✔
78
        }
79

80
        @Override
81
        public Word<I> getSuffix() {
82
            return originalQuery.getSuffix();
1✔
83
        }
84

85
        @Override
86
        public String toString() {
87
            return originalQuery.toString();
×
88
        }
89

90
    }
91

92
}
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