Remove ABIVersion.MAGNESIUM
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / ABIVersion.java
index bbea1a96551dde0be9f16d16a733ad1aff9e742f..119d477cc6e77df384c1807af1490094e084fb1a 100644 (file)
@@ -9,23 +9,19 @@ package org.opendaylight.controller.cluster.access;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
-import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
 import org.opendaylight.yangtools.concepts.WritableObject;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Enumeration of all ABI versions supported by this implementation of the client access API.
- *
- * @author Robert Varga
  */
-@Beta
 public enum ABIVersion implements WritableObject {
     // NOTE: enumeration values need to be sorted in ascending order of their version to keep Comparable working
 
@@ -40,25 +36,19 @@ public enum ABIVersion implements WritableObject {
         }
     },
 
-    /**
-     * Initial ABI version, as shipped with Boron Simultaneous release.
-     */
-    // We seed the initial version to be the same as DataStoreVersions.BORON-VERSION for compatibility reasons.
-    BORON(5) {
-        @Override
-        public NormalizedNodeStreamVersion getStreamVersion() {
-            return NormalizedNodeStreamVersion.LITHIUM;
-        }
-    },
+    // BORON was 5
+    // NEON_SR2 was 6
+    // SODIUM_SR1 was 7
+    // MAGNESIUM was 8
 
     /**
-     * Revised ABI version. The messages remain the same as {@link #BORON}, but messages bearing QNames in any shape
-     * are using {@link NormalizedNodeStreamVersion#SODIUM}, which improves encoding.
+     * Oldest ABI version we support. The messages remain the same as {@code MAGNESIUM}, the serialization proxies in
+     * use are flat objects without any superclasses.
      */
-    SODIUM(6) {
+    CHLORINE_SR2(9) {
         @Override
         public NormalizedNodeStreamVersion getStreamVersion() {
-            return NormalizedNodeStreamVersion.SODIUM;
+            return NormalizedNodeStreamVersion.MAGNESIUM;
         }
     },
 
@@ -98,7 +88,7 @@ public enum ABIVersion implements WritableObject {
      * @return Current {@link ABIVersion}
      */
     public static @NonNull ABIVersion current() {
-        return SODIUM;
+        return CHLORINE_SR2;
     }
 
     /**
@@ -111,20 +101,22 @@ public enum ABIVersion implements WritableObject {
      * @throws PastVersionException if the specified integer identifies a past version which is no longer supported
      */
     public static @NonNull ABIVersion valueOf(final short value) throws FutureVersionException, PastVersionException {
-        switch (Short.toUnsignedInt(value)) {
-            case 0:
-            case 1:
-            case 2:
-            case 3:
-            case 4:
-                throw new PastVersionException(value, BORON);
-            case 5:
-                return BORON;
-            case 6:
-                return SODIUM;
-            default:
-                throw new FutureVersionException(value, SODIUM);
-        }
+        return switch (Short.toUnsignedInt(value)) {
+            case 0, 1, 2, 3, 4, 6, 7, 8 -> throw new PastVersionException(value, CHLORINE_SR2);
+            case 9 -> CHLORINE_SR2;
+            default -> throw new FutureVersionException(value, CHLORINE_SR2);
+        };
+    }
+
+    /**
+     * Return {@code true} if this version is earier than some {@code other} version.
+     *
+     * @param other Other {@link ABIVersion}
+     * @return {@code true} if {@code other is later}
+     * @throws NullPointerException if {@code other} is null
+     */
+    public boolean lt(final @NonNull ABIVersion other) {
+        return compareTo(other) < 0;
     }
 
     @Override