/*
 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.data.codec.binfmt;

import com.google.common.annotations.Beta;
import java.io.DataOutput;
import java.math.BigInteger;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.yangtools.yang.common.Uint64;
import org.opendaylight.yangtools.yang.data.api.schema.ValueNode;

/**
 * Enumeration of all stream versions this implementation supports on both input and output.
 */
@Beta
@NonNullByDefault
public enum NormalizedNodeStreamVersion {
    /**
     * Original stream version, as shipped in OpenDaylight Lithium simultaneous release. The caveat here is that this
     * version has augmented in OpenDaylight Oxygen to retrofit a non-null representation of the empty type.
     *
     * @deprecated This version is a historic one and should not be used in code. It does not support current mapping
     *             of {@code Uint8} et al. and hence results in a stream which needs to be further adapted to current
     *             definition of LeafNode.
     */
    @Deprecated
    LITHIUM {
        @Override
        public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
            return new LithiumNormalizedNodeOutputStreamWriter(output);
        }
    },
    /**
     * Updated stream version, as shipped in OpenDaylight Neon SR2 release. Improves identifier encoding over
     * {@link #LITHIUM}, so that QName caching is more effective.
     *
     * @deprecated This version is a historic one and should not be used in code. It does not support current mapping
     *             of {@code Uint8} et al. and hence results in a stream which needs to be further adapted to current
     *             definition of LeafNode.
     */
    @Deprecated
    NEON_SR2 {
        @Override
        public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
            return new NeonSR2NormalizedNodeOutputStreamWriter(output);
        }
    },
    /**
     * First shipping in Sodium SR1. Improved stream coding to eliminate redundancies present in {@link #NEON_SR2}.
     * Supports {@code Uint8} et al. as well as {@link BigInteger}.
     */
    SODIUM_SR1 {
        @Override
        public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
            return new SodiumSR1DataOutput(output);
        }
    },
    /**
     * First shipping is Magnesium. Does not support {@link BigInteger} mirroring it being superseded by {@link Uint64}
     * in {@link ValueNode#getValue()}.
     */
    MAGNESIUM {
        @Override
        public NormalizedNodeDataOutput newDataOutput(final DataOutput output) {
            return new MagnesiumDataOutput(output);
        }
    };

    /**
     * Return the current runtime version. Guaranteed to not throw {@link UnsupportedOperationException} from
     * {@link #newDataOutput(DataOutput)}.
     *
     * @return Current runtime version.
     */
    public static NormalizedNodeStreamVersion current() {
        return MAGNESIUM;
    }

    /**
     * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
     *
     * @param output the DataOutput to write to
     * @return a new {@link NormalizedNodeDataOutput} instance
     * @throws NullPointerException if {@code output} is null
     * @throws UnsupportedOperationException if this version cannot be created in this runtime
     */
    public abstract NormalizedNodeDataOutput newDataOutput(DataOutput output);
}

@@ -1035,33 +1035,100 @@
 pty type.%0A     *
-%0A
+/%0A    LITHIUM %7B%0A        /**%0A         * %7B@inheritDoc%7D%0A         *%0A    
      * @deprecat
@@ -1216,33 +1216,29 @@
 port current
- mapping%0A
+%0A    
      *      
@@ -1236,32 +1236,40 @@
   *             
+mapping 
 of %7B@code Uint8%7D
@@ -1335,36 +1335,29 @@
 ther adapted
- to current%0A
+%0A    
      *      
@@ -1355,32 +1355,43 @@
   *             
+to current 
 definition of Le
@@ -1395,39 +1395,47 @@
  LeafNode.%0A     
+    
 */%0A    
+  
+  
 @Deprecated%0A    
@@ -1430,30 +1430,16 @@
 recated%0A
-    LITHIUM %7B%0A
         
@@ -1800,33 +1800,101 @@
 ffective.%0A     *
+/
 %0A
+    NEON_SR2 %7B%0A        /**%0A         * %7B@inheritDoc%7D%0A         *%0A    
      * @deprecat
@@ -1990,17 +1990,13 @@
 rent
- mapping%0A
+%0A    
     
@@ -2010,16 +2010,24 @@
         
+mapping 
 of %7B@cod
@@ -2109,20 +2109,13 @@
 pted
- to current%0A
+%0A    
     
@@ -2129,16 +2129,27 @@
         
+to current 
 definiti
@@ -2169,23 +2169,31 @@
 e.%0A     
-*/%0A
+    */%0A   
     
+ 
 @Depreca
@@ -2196,31 +2196,16 @@
 recated%0A
-    NEON_SR2 %7B%0A
         

Move NormalizedNodeStreamVersion deprecation