• 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

76.47
/commons/counterexamples/src/main/java/de/learnlib/acex/AcexAnalyzers.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.acex;
17

18
import java.util.Collection;
19
import java.util.Collections;
20
import java.util.HashMap;
21
import java.util.Map;
22

23
/**
24
 * This is a utility class, acting as a container for several {@link AbstractNamedAcexAnalyzer}s.
25
 */
26
public final class AcexAnalyzers {
27

28
    /**
29
     * Analyzer that linearly scans through the abstract counterexample in ascending order.
30
     */
31
    public static final AbstractNamedAcexAnalyzer LINEAR_FWD = new AbstractNamedAcexAnalyzer("LinearFwd") {
2✔
32

33
        @Override
34
        public int analyzeAbstractCounterexample(AbstractCounterexample<?> acex, int low, int high) {
35
            return AcexAnalysisAlgorithms.linearSearchFwd(acex, low, high);
2✔
36
        }
37
    };
38

39
    /**
40
     * Analyzer that linearly scans through the abstract counterexample in descending order.
41
     */
42
    public static final AbstractNamedAcexAnalyzer LINEAR_BWD = new AbstractNamedAcexAnalyzer("LinearBwd") {
2✔
43

44
        @Override
45
        public int analyzeAbstractCounterexample(AbstractCounterexample<?> acex, int low, int high) {
46
            return AcexAnalysisAlgorithms.linearSearchBwd(acex, low, high);
2✔
47
        }
48
    };
49
    /**
50
     * Analyzer that searches for a suffix index using binary search.
51
     */
52
    public static final AbstractNamedAcexAnalyzer BINARY_SEARCH_BWD = new AbstractNamedAcexAnalyzer("BinarySearchBwd") {
2✔
53

54
        @Override
55
        public int analyzeAbstractCounterexample(AbstractCounterexample<?> acex, int low, int high) {
56
            return AcexAnalysisAlgorithms.binarySearchRight(acex, low, high);
2✔
57
        }
58
    };
59
    public static final AbstractNamedAcexAnalyzer BINARY_SEARCH_FWD = new AbstractNamedAcexAnalyzer("BinarySearchFwd") {
2✔
60

61
        @Override
62
        public int analyzeAbstractCounterexample(AbstractCounterexample<?> acex, int low, int high) {
63
            return AcexAnalysisAlgorithms.binarySearchLeft(acex, low, high);
2✔
64
        }
65
    };
66
    /**
67
     * Analyzer that searches for a suffix index using exponential search.
68
     */
69
    public static final AbstractNamedAcexAnalyzer EXPONENTIAL_BWD = new AbstractNamedAcexAnalyzer("ExponentialBwd") {
2✔
70

71
        @Override
72
        public int analyzeAbstractCounterexample(AbstractCounterexample<?> acex, int low, int high) {
73
            return AcexAnalysisAlgorithms.exponentialSearchBwd(acex, low, high);
2✔
74
        }
75
    };
76
    public static final AbstractNamedAcexAnalyzer EXPONENTIAL_FWD = new AbstractNamedAcexAnalyzer("ExponentialFwd") {
2✔
77

78
        @Override
79
        public int analyzeAbstractCounterexample(AbstractCounterexample<?> acex, int low, int high) {
80
            return AcexAnalysisAlgorithms.exponentialSearchFwd(acex, low, high);
2✔
81
        }
82
    };
83
    public static final Map<String, AbstractNamedAcexAnalyzer> FWD_ANALYZERS =
2✔
84
            createMap(LINEAR_FWD, EXPONENTIAL_FWD, BINARY_SEARCH_FWD);
2✔
85

86
    public static final Map<String, AbstractNamedAcexAnalyzer> BWD_ANALYZERS =
2✔
87
            createMap(LINEAR_BWD, EXPONENTIAL_BWD, BINARY_SEARCH_BWD);
2✔
88
    public static final Map<String, AbstractNamedAcexAnalyzer> ALL_ANALYZERS = createMap(FWD_ANALYZERS, BWD_ANALYZERS);
2✔
89

90
    private AcexAnalyzers() {
91
        // prevent instantiation
92
    }
93

94
    private static Map<String, AbstractNamedAcexAnalyzer> createMap(AbstractNamedAcexAnalyzer... analyzers) {
95
        Map<String, AbstractNamedAcexAnalyzer> analyzerMap = new HashMap<>(analyzers.length * 3 / 2);
2✔
96
        for (AbstractNamedAcexAnalyzer a : analyzers) {
2✔
97
            analyzerMap.put(a.getName(), a);
2✔
98
        }
99
        return Collections.unmodifiableMap(analyzerMap);
2✔
100
    }
101

102
    @SafeVarargs
103
    private static Map<String, AbstractNamedAcexAnalyzer> createMap(Map<String, AbstractNamedAcexAnalyzer>... maps) {
104
        Map<String, AbstractNamedAcexAnalyzer> result = new HashMap<>();
2✔
105
        for (Map<String, AbstractNamedAcexAnalyzer> map : maps) {
2✔
106
            result.putAll(map);
2✔
107
        }
108
        return result;
2✔
109
    }
110

111
    public static Collection<AbstractNamedAcexAnalyzer> getAnalyzers(Direction dir) {
NEW
112
        return switch (dir) {
×
NEW
113
            case FORWARD -> getForwardAnalyzers();
×
NEW
114
            case BACKWARD -> getBackwardAnalyzers();
×
115
        };
116
    }
117

118
    public static Collection<AbstractNamedAcexAnalyzer> getForwardAnalyzers() {
119
        return FWD_ANALYZERS.values();
×
120
    }
121

122
    public static Collection<AbstractNamedAcexAnalyzer> getBackwardAnalyzers() {
123
        return BWD_ANALYZERS.values();
×
124
    }
125

126
    public static Collection<AbstractNamedAcexAnalyzer> getAllAnalyzers() {
127
        return ALL_ANALYZERS.values();
2✔
128
    }
129

130
    public enum Direction {
×
131
        FORWARD,
×
132
        BACKWARD
×
133
    }
134

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