681553eb587825e83d28b1522f76ab3959067cda
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / 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.controller.cluster.datastore.node.utils.stream;
9
10 import com.google.common.annotations.Beta;
11 import java.io.DataOutput;
12 import java.io.IOException;
13 import org.eclipse.jdt.annotation.NonNull;
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
21 /**
22  * Interface for emitting {@link NormalizedNode}s, {@link YangInstanceIdentifier}s, {@link PathArgument}s
23  * and {@link SchemaPath}s.
24  */
25 @Beta
26 public interface NormalizedNodeDataOutput extends AutoCloseable, DataOutput {
27     void writeQName(@NonNull QName qname) throws IOException;
28
29     void writeNormalizedNode(@NonNull NormalizedNode<?, ?> normalizedNode) throws IOException;
30
31     void writePathArgument(PathArgument pathArgument) throws IOException;
32
33     void writeYangInstanceIdentifier(YangInstanceIdentifier identifier) throws IOException;
34
35     void writeSchemaPath(SchemaPath path) throws IOException;
36
37     @Override
38     void close() throws IOException;
39
40     default void writeOptionalNormalizedNode(final @Nullable NormalizedNode<?, ?> normalizedNode) throws IOException {
41         if (normalizedNode != null) {
42             writeBoolean(true);
43             writeNormalizedNode(normalizedNode);
44         } else {
45             writeBoolean(false);
46         }
47     }
48 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.