c2db375b044b91c3522d51db814d70ce4203f29e
[yangtools.git] / yang / yang-data-codec-binfmt / src / main / java / org / opendaylight / yangtools / yang / data / codec / binfmt / NormalizedNodeDataOutput.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.binfmt;
9
10 import com.google.common.annotations.Beta;
11 import java.io.DataOutput;
12 import java.io.IOException;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
21
22 /**
23  * Interface for emitting {@link NormalizedNode}s, {@link YangInstanceIdentifier}s, {@link PathArgument}s
24  * and {@link SchemaPath}s.
25  */
26 @Beta
27 @NonNullByDefault
28 public interface NormalizedNodeDataOutput extends AutoCloseable, DataOutput {
29     void writeQName(QName qname) throws IOException;
30
31     void writeNormalizedNode(NormalizedNode<?, ?> normalizedNode) throws IOException;
32
33     void writePathArgument(PathArgument pathArgument) throws IOException;
34
35     void writeYangInstanceIdentifier(YangInstanceIdentifier identifier) throws IOException;
36
37     @Deprecated(forRemoval = true)
38     void writeSchemaPath(SchemaPath path) throws IOException;
39
40     void writeSchemaNodeIdentifier(SchemaNodeIdentifier path) throws IOException;
41
42     @Override
43     void close() throws IOException;
44
45     default void writeOptionalNormalizedNode(final @Nullable NormalizedNode<?, ?> normalizedNode) throws IOException {
46         if (normalizedNode != null) {
47             writeBoolean(true);
48             writeNormalizedNode(normalizedNode);
49         } else {
50             writeBoolean(false);
51         }
52     }
53 }