Switch default output stream version
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / NormalizedNodeDataInput.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.DataInput;
12 import java.io.IOException;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
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 reading {@link NormalizedNode}s, {@link YangInstanceIdentifier}s, {@link PathArgument}s
23  * and {@link SchemaPath}s.
24  */
25 @Beta
26 public interface NormalizedNodeDataInput extends DataInput {
27     /**
28      * Read a normalized node from the reader.
29      *
30      * @return Next node from the stream, or null if end of stream has been reached.
31      * @throws IOException if an error occurs
32      * @throws IllegalStateException if the dictionary has been detached
33      */
34     NormalizedNode<?, ?> readNormalizedNode() throws IOException;
35
36     YangInstanceIdentifier readYangInstanceIdentifier() throws IOException;
37
38     @NonNull QName readQName() throws IOException;
39
40     PathArgument readPathArgument() throws IOException;
41
42     SchemaPath readSchemaPath() throws IOException;
43
44     /**
45      * Return the version of the underlying input stream.
46      *
47      * @return Stream version
48      * @throws IOException if the version cannot be ascertained
49      */
50     NormalizedNodeStreamVersion getVersion() throws IOException;
51
52     default Optional<NormalizedNode<?, ?>> readOptionalNormalizedNode() throws IOException {
53         return readBoolean() ? Optional.of(readNormalizedNode()) : Optional.empty();
54     }
55 }