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.
27 // FIXME: 5.0.0: consider deprecating this version
30 public NormalizedNodeDataOutput newDataOutput(DataOutput output) {
31 return new LithiumNormalizedNodeOutputStreamWriter(output);
35 * Updated stream version, as shipped in OpenDaylight Neon SR2 release. Improves identifier encoding over
36 * {@link #LITHIUM}, so that QName caching is more effective.
40 public NormalizedNodeDataOutput newDataOutput(DataOutput output) {
41 return new NeonSR2NormalizedNodeOutputStreamWriter(output);
45 * First shipping in Sodium SR1. Improved stream coding to eliminate redundancies present in {@link #NEON_SR2}.
46 * Supports {code Uint8} et al. as well as {@link BigInteger}.
50 public NormalizedNodeDataOutput newDataOutput(DataOutput output) {
51 return new SodiumSR1DataOutput(output);
55 * First shipping is Magnesium. Does not support {@link BigInteger} mirroring it being superseded by {@link Uint64}
56 * in {@link ValueNode#getValue()}.
60 public NormalizedNodeDataOutput newDataOutput(DataOutput output) {
61 return new MagnesiumDataOutput(output);
66 * Return the current runtime version. Guaranteed to not throw {@link UnsupportedOperationException} from
67 * {@link #newDataOutput(DataOutput)}.
69 * @return Current runtime version.
71 public static NormalizedNodeStreamVersion current() {
76 * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
78 * @param output the DataOutput to write to
79 * @return a new {@link NormalizedNodeDataOutput} instance
80 * @throws NullPointerException if {@code output} is null
81 * @throws UnsupportedOperationException if this version cannot be created in this runtime
83 public abstract NormalizedNodeDataOutput newDataOutput(DataOutput output);