2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.codec.binfmt;
10 import com.google.common.annotations.Beta;
11 import java.io.DataOutput;
12 import java.math.BigInteger;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.yang.common.Uint64;
15 import org.opendaylight.yangtools.yang.data.api.schema.ValueNode;
18 * Enumeration of all stream versions this implementation supports on both input and output.
22 public enum NormalizedNodeStreamVersion {
24 * Original stream version, as shipped in OpenDaylight Lithium simultaneous release. The caveat here is that this
25 * version has augmented in OpenDaylight Oxygen to retrofit a non-null representation of the empty type.
31 * @deprecated This version is a historic one and should not be used in code. It does not support current
32 * mapping of {@code Uint8} et al. and hence results in a stream which needs to be further adapted
33 * to current definition of LeafNode.
37 public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
38 return new LithiumNormalizedNodeOutputStreamWriter(output);
42 * Updated stream version, as shipped in OpenDaylight Neon SR2 release. Improves identifier encoding over
43 * {@link #LITHIUM}, so that QName caching is more effective.
49 * @deprecated This version is a historic one and should not be used in code. It does not support current
50 * mapping of {@code Uint8} et al. and hence results in a stream which needs to be further adapted
51 * to current definition of LeafNode.
55 public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
56 return new NeonSR2NormalizedNodeOutputStreamWriter(output);
60 * First shipping in Sodium SR1. Improved stream coding to eliminate redundancies present in {@link #NEON_SR2}.
61 * Supports {@code Uint8} et al. as well as {@link BigInteger}.
65 public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
66 return new SodiumSR1DataOutput(output);
70 * First shipping is Magnesium. Does not support {@link BigInteger} mirroring it being superseded by {@link Uint64}
71 * in {@link ValueNode#body()}.
75 public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
76 return new MagnesiumDataOutput(output);
81 * Return the current runtime version. Guaranteed to not throw {@link UnsupportedOperationException} from
82 * {@link #newDataOutput(DataOutput)}.
84 * @return Current runtime version.
86 public static NormalizedNodeStreamVersion current() {
91 * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
93 * @param output the DataOutput to write to
94 * @return a new {@link NormalizedNodeDataOutput} instance
95 * @throws NullPointerException if {@code output} is null
96 * @throws UnsupportedOperationException if this version cannot be created in this runtime
98 public abstract NormalizedNodeDataOutput newDataOutput(DataOutput output);