Do not pretty-print body class
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / NormalizedAnydata.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;
9
10 import com.google.common.annotations.Beta;
11 import java.io.IOException;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
15 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference;
17
18 /**
19  * The contents of an {@code anydata} node in a normalized format. This representation acts as a schema-bound bridge
20  * between the various (mostly parser-based) representations. Implementations of this interface are usually created
21  * from an instance of {@link NormalizableAnydata}.
22  *
23  * <p>
24  * Note this interface does not have an equality contract and implementations are expected to default to identity
25  * equality (or in Valhalla-speak: be plain data).
26  */
27 @Beta
28 @NonNullByDefault
29 public interface NormalizedAnydata extends Immutable {
30     /**
31      * Return the {@link EffectiveStatementInference} which describes the structure returned by {@link #getData()}.
32      *
33      * @return An {@link EffectiveStatementInference}
34      */
35     EffectiveStatementInference getInference();
36
37     /**
38      * Return the {@link NormalizedNode} representation of this node's data. Information about the corresponding schema
39      * is available via {@link #getInference()}.
40      *
41      * @return A {@link NormalizedNode}
42      */
43     NormalizedNode getData();
44
45     default void writeTo(final NormalizedNodeStreamWriter writer) throws IOException {
46         writeTo(writer, true);
47     }
48
49     default void writeTo(final NormalizedNodeStreamWriter writer, final boolean orderKeyLeaves) throws IOException {
50         NormalizedNodeWriter.forStreamWriter(writer, orderKeyLeaves).write(getData()).flush();
51     }
52 }