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

LearnLib / automatalib / 10220057657

02 Aug 2024 06:06PM UTC coverage: 90.366% (+0.3%) from 90.072%
10220057657

push

github

mtf90
overhaul serizalition code

* unify access to Input(De)Serializers behind facades to leverage the default methods for various input/output channels
* drop implicit buffering/decompressing as this should be decided where the stream are constructed (user-land)
* remove/cleanup the (now) unused code

300 of 349 new or added lines in 33 files covered. (85.96%)

9 existing lines in 3 files now uncovered.

15927 of 17625 relevant lines covered (90.37%)

1.67 hits per line

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

80.0
/serialization/taf/src/main/java/net/automatalib/serialization/taf/writer/TAFWriters.java
1
/* Copyright (C) 2013-2024 TU Dortmund University
2
 * This file is part of AutomataLib, http://www.automatalib.net/.
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 net.automatalib.serialization.taf.writer;
17

18
import java.util.Collection;
19
import java.util.Collections;
20

21
import net.automatalib.automaton.FiniteAlphabetAutomaton;
22
import net.automatalib.automaton.fsa.DFA;
23
import net.automatalib.automaton.transducer.MealyMachine;
24
import net.automatalib.serialization.InputModelSerializer;
25

26
/**
27
 * Facade for TAF (textual automaton format) writing. This class provides several static methods to access
28
 * {@link InputModelSerializer}s for TAF descriptions of {@link DFA}s and {@link MealyMachine}s.
29
 */
30
public final class TAFWriters {
31

32
    private TAFWriters() {
33
        // prevent instantiation
34
    }
35

36
    /**
37
     * Returns an {@link InputModelSerializer} for writing {@link DFA}s.
38
     *
39
     * @param <S>
40
     *         state type
41
     * @param <I>
42
     *         input symbol type
43
     * @param <A>
44
     *         (concrete) automaton type
45
     *
46
     * @return an {@link InputModelSerializer} for writing {@link DFA}s
47
     */
48
    public static <S, I, A extends DFA<S, I>> InputModelSerializer<I, A> dfa() {
49
        return new TAFConcreteWriter<>("dfa", TAFWriters::extractSPDFA);
2✔
50
    }
51

52
    /**
53
     * Returns an {@link InputModelSerializer} for writing {@link MealyMachine}s.
54
     *
55
     * @param <S>
56
     *         state type
57
     * @param <I>
58
     *         input symbol type
59
     * @param <T>
60
     *         transition type
61
     * @param <O>
62
     *         output symbol type
63
     * @param <A>
64
     *         (concrete) automaton type
65
     *
66
     * @return an {@link InputModelSerializer} for writing {@link MealyMachine}s
67
     */
68
    public static <S, I, T, O, A extends MealyMachine<S, I, T, O>> InputModelSerializer<I, A> mealy() {
69
        return new TAFConcreteWriter<>("mealy", TAFWriters::extractSPMealy);
2✔
70
    }
71

72
    /**
73
     * Returns an {@link InputModelSerializer} for writing generic {@link FiniteAlphabetAutomaton}s. During
74
     * serialization, the writer checks whether the given automaton is either a {@link DFA} or a {@link MealyMachine}
75
     * and delegates to the respective serializers.
76
     *
77
     * @param <S>
78
     *         state type
79
     * @param <I>
80
     *         input symbol type
81
     * @param <T>
82
     *         transition type
83
     * @param <A>
84
     *         (concrete) automaton type
85
     *
86
     * @return an {@link InputModelSerializer} for writing {@link FiniteAlphabetAutomaton}s
87
     *
88
     * @see #dfa()
89
     * @see #mealy()
90
     */
91
    public static <S, I, T, A extends FiniteAlphabetAutomaton<S, I, T>> InputModelSerializer<I, A> any() {
NEW
92
        return new TAFAnyWriter<>();
×
93
    }
94

95
    static <S> Collection<String> extractSPDFA(DFA<S, ?> dfa, S state) {
96
        return dfa.isAccepting(state) ? Collections.singleton("accepting") : Collections.emptySet();
2✔
97
    }
98

99
    static <S> Collection<String> extractSPMealy(MealyMachine<S, ?, ?, ?> dfa, S state) {
100
        return Collections.emptySet();
2✔
101
    }
102

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