Disconnect JSONCodec from JsonWriter
[yangtools.git] / codec / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / JSONValueWriter.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.codec.gson;
9
10 import java.io.IOException;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12
13 /**
14  * A handler used to write out JSON-encoded values.
15  */
16 @NonNullByDefault
17 public interface JSONValueWriter {
18     /**
19      * Write a {@code boolean} value, as per
20      * <a href="https://www.rfc-editor.org/rfc/rfc7951#section-6.3">RFC7951, section 6.3</a>.
21      *
22      * @param value Value to write
23      * @throws IOException when an IO error occurs
24      */
25     void writeBoolean(boolean value) throws IOException;
26
27     /**
28      * Write an {@code empty} value, as per
29      * <a href="https://www.rfc-editor.org/rfc/rfc7951#section-6.9">RFC7951, section 6.9</a>.
30      *
31      * @throws IOException when an IO error occurs
32      */
33     void writeEmpty() throws IOException;
34
35     /**
36      * Write a numeric value, as per
37      * <a href="https://www.rfc-editor.org/rfc/rfc7951#section-6.1">RFC7951, section 6.1</a>.
38      *
39      * @param value Value to write
40      * @throws IOException when an IO error occurs
41      */
42     void writeNumber(Number value) throws IOException;
43
44     /**
45      * Write a string value, as per
46      * <a href="https://www.rfc-editor.org/rfc/rfc7951#section-6.2">RFC7951, section 6.2</a> and other types which have
47      * are represented as JSON strings.
48      *
49      * @param value Value to write
50      * @throws IOException when an IO error occurs
51      */
52     void writeString(String value) throws IOException;
53 }