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

LearnLib / automatalib / 31586418187

12 Aug 2026 09:53AM UTC coverage: 92.921% (+0.9%) from 92.059%
31586418187

push

github

mtf90
use new version scheme

17615 of 18957 relevant lines covered (92.92%)

1.72 hits per line

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

60.0
/api/src/main/java/net/automatalib/serialization/InputModelSerializer.java
1
/* Copyright (C) 2013-2026 TU Dortmund University
2
 * This file is part of AutomataLib <https://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;
17

18
import java.io.File;
19
import java.io.IOException;
20
import java.io.OutputStream;
21
import java.nio.charset.StandardCharsets;
22

23
import net.automatalib.alphabet.Alphabet;
24
import net.automatalib.common.util.IOUtil;
25
import net.automatalib.ts.simple.SimpleTS;
26

27
/**
28
 * A refinement of the {@link ModelSerializer} interface for arbitrary models that can react to inputs. Introduces a new
29
 * type variable for the input symbol type and limits the model type to {@link SimpleTS}s.
30
 *
31
 * @param <I>
32
 *         the type of input symbols
33
 * @param <M>
34
 *         the type of objects implementing classes can deserialize
35
 */
36
@FunctionalInterface
37
public interface InputModelSerializer<I, M> extends ModelSerializer<InputModelData<I, M>> {
38

39
    /**
40
     * Writes the model to the given output stream. If the format is a textual one, the output is typically encoded in
41
     * {@link StandardCharsets#UTF_8 UTF-8}.
42
     * <p>
43
     * Note: the output stream will <b>not</b> be closed.
44
     *
45
     * @param os
46
     *         the output stream to write to
47
     * @param model
48
     *         the model to write
49
     * @param alphabet
50
     *         the inputs of the model to which serialization should be limited
51
     *
52
     * @throws IOException
53
     *         when writing to the output stream fails.
54
     */
55
    void writeModel(OutputStream os, M model, Alphabet<I> alphabet) throws IOException;
56

57
    /**
58
     * Writes the model to the given file. If the format is a textual one, the output is typically encoded in
59
     * {@link StandardCharsets#UTF_8 UTF-8}.
60
     *
61
     * @param f
62
     *         the file to write to
63
     * @param model
64
     *         the model to write
65
     * @param alphabet
66
     *         the inputs of the model to which serialization should be limited
67
     *
68
     * @throws IOException
69
     *         when writing to the output stream fails.
70
     */
71
    default void writeModel(File f, M model, Alphabet<I> alphabet) throws IOException {
72
        try (OutputStream os = IOUtil.asBufferedOutputStream(f)) {
1✔
73
            writeModel(os, model, alphabet);
1✔
74
        }
75
    }
1✔
76

77
    @Override
78
    default void writeModel(OutputStream os, InputModelData<I, M> model) throws IOException {
79
        writeModel(os, model.model, model.alphabet);
×
80
    }
×
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc