Do not pretty-print body class
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / stream / ReusableStreamReceiver.java
1 /*
2  * Copyright (c) 2019 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.api.schema.stream;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
12
13 /**
14  * Utility marker interface for {@link NormalizedNodeStreamWriter} implementations which can be reused multiple times
15  * and can expose a {@link NormalizedNode} result of each complete streaming use.
16  *
17  * <p>
18  * An example of use would be:
19  * <pre>
20  *   ReusableStreamReceiver writer;
21  *   final NormalizedNode result;
22  *
23  *   try {
24  *       // pipe events into writer:
25  *       writer.startContainer(...);
26  *       ...
27  *
28  *       result = writer.getResult();
29  *   } finally {
30  *       writer.reset();
31  *   }
32  * </pre>
33  *
34  * <p>
35  * Note the writer should always be {@link #reset()} in a {@code finally} block, so that any streaming state is
36  * properly discarded.
37  */
38 @Beta
39 public interface ReusableStreamReceiver extends NormalizedNodeStreamWriter {
40     /**
41      * Acquire the result of the last streaming session.
42      *
43      * @return Result of streaming.
44      */
45     NormalizedNode getResult();
46
47     /**
48      * Reset this writer to initial state.
49      */
50     void reset();
51 }