• 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

0.0
/api/src/main/java/net/automatalib/serialization/ModelSerializer.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.common.util.IOUtil;
24

25
/**
26
 * A generic interface for formalizing an arbitrary serializer for a given model type.
27
 *
28
 * @param <M>
29
 *         the type of objects implementing classes can serialize
30
 */
31
@FunctionalInterface
32
public interface ModelSerializer<M> {
33

34
    /**
35
     * Writes the model to the given output stream. If the format is a textual one, the output is typically encoded in
36
     * {@link StandardCharsets#UTF_8 UTF-8}.
37
     * <p>
38
     * Note: the output stream will <b>not</b> be closed.
39
     *
40
     * @param os
41
     *         the output stream to write to
42
     * @param model
43
     *         the model to write
44
     *
45
     * @throws IOException
46
     *         when writing to the output stream fails.
47
     */
48
    void writeModel(OutputStream os, M model) throws IOException;
49

50
    /**
51
     * Writes the model to the given file. If the format is a textual one, the output is typically encoded in
52
     * {@link StandardCharsets#UTF_8 UTF-8}.
53
     *
54
     * @param f
55
     *         the file to write to
56
     * @param model
57
     *         the model to write
58
     *
59
     * @throws IOException
60
     *         when writing to the output stream fails.
61
     */
62
    default void writeModel(File f, M model) throws IOException {
63
        try (OutputStream os = IOUtil.asBufferedOutputStream(f)) {
×
64
            writeModel(os, model);
×
65
        }
66
    }
×
67

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