More cds-access-api cleanup
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / Message.java
index 2bc33cd1e4bc6c6ec5fc45271e48e941ccdbbfa1..6ee547fc93e75a8acf80a4b0e2f5c4f8ace4be55 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.controller.cluster.access.concepts;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
+import java.io.Serial;
 import java.io.Serializable;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.access.ABIVersion;
@@ -47,14 +47,12 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier;
  * Note that this class specifies the {@link Immutable} contract, which means that all subclasses must follow this API
  * contract.
  *
- * @author Robert Varga
- *
  * @param <T> Target identifier type
  * @param <C> Message type
  */
-@Beta
 public abstract class Message<T extends WritableIdentifier, C extends Message<T, C>> implements Immutable,
         Serializable {
+    @Serial
     private static final long serialVersionUID = 1L;
 
     private final @NonNull ABIVersion version;
@@ -110,17 +108,10 @@ public abstract class Message<T extends WritableIdentifier, C extends Message<T,
             return (C)this;
         }
 
-        switch (toVersion) {
-            case BORON:
-                return verifyNotNull(cloneAsVersion(toVersion));
-            case TEST_PAST_VERSION:
-            case TEST_FUTURE_VERSION:
-            default:
-                // Fall-through to throw
-                break;
-        }
-
-        throw new IllegalArgumentException("Unhandled ABI version " + toVersion);
+        return switch (toVersion) {
+            case BORON, NEON_SR2, SODIUM_SR1, MAGNESIUM -> verifyNotNull(cloneAsVersion(toVersion));
+            default -> throw new IllegalArgumentException("Unhandled ABI version " + toVersion);
+        };
     }
 
     /**
@@ -161,6 +152,7 @@ public abstract class Message<T extends WritableIdentifier, C extends Message<T,
      */
     abstract @NonNull AbstractMessageProxy<T, C> externalizableProxy(@NonNull ABIVersion reqVersion);
 
+    @Serial
     protected final Object writeReplace() {
         return externalizableProxy(version);
     }