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

LearnLib / automatalib / 13815628111

12 Mar 2025 03:46PM CUT coverage: 92.058% (-0.001%) from 92.059%
13815628111

push

github

mtf90
cleanup redundant type variable definitions

1 of 1 new or added line in 1 file covered. (100.0%)

16599 of 18031 relevant lines covered (92.06%)

1.7 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-2025 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
public interface ModelSerializer<M> {
32

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

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

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

© 2025 Coveralls, Inc