• 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

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

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

23
import de.learnlib.acex.AbstractCounterexample;
24

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

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

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

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

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

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

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

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

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

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

92
    private AcexAnalyzers() {
93
        // prevent instantiation
94
    }
95

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

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

113
    public static Collection<AbstractNamedAcexAnalyzer> getAnalyzers(Direction dir) {
114
        switch (dir) {
×
115
            case FORWARD:
116
                return getForwardAnalyzers();
×
117
            case BACKWARD:
118
                return getBackwardAnalyzers();
×
119
            default:
120
                throw new IllegalArgumentException();
×
121
        }
122
    }
123

124
    public static Collection<AbstractNamedAcexAnalyzer> getForwardAnalyzers() {
125
        return FWD_ANALYZERS.values();
×
126
    }
127

128
    public static Collection<AbstractNamedAcexAnalyzer> getBackwardAnalyzers() {
129
        return BWD_ANALYZERS.values();
×
130
    }
131

132
    public static Collection<AbstractNamedAcexAnalyzer> getAllAnalyzers() {
133
        return ALL_ANALYZERS.values();
2✔
134
    }
135

136
    public enum Direction {
×
137
        FORWARD,
×
138
        BACKWARD
×
139
    }
140

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