Bump versions 9.0.4-SNAPSHOT
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / TransactionIdentifier.java
index d2a92ea1913374a2dfa693195f27f1916938d347..ea72c847501a79a8982af88b1fd6aadfc90784c4 100644 (file)
@@ -9,59 +9,20 @@ package org.opendaylight.controller.cluster.access.concepts;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.annotations.Beta;
 import java.io.DataInput;
 import java.io.DataOutput;
-import java.io.Externalizable;
 import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.WritableIdentifier;
 import org.opendaylight.yangtools.concepts.WritableObjects;
 
 /**
  * Globally-unique identifier of a transaction.
- *
- * @author Robert Varga
  */
-@Beta
 public final class TransactionIdentifier implements WritableIdentifier {
-    private static final class Proxy implements Externalizable {
-        private static final long serialVersionUID = 1L;
-        private LocalHistoryIdentifier historyId;
-        private long transactionId;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // For Externalizable
-        }
-
-        Proxy(final LocalHistoryIdentifier historyId, final long transactionId) {
-            this.historyId = requireNonNull(historyId);
-            this.transactionId = transactionId;
-        }
-
-        @Override
-        public void writeExternal(final ObjectOutput out) throws IOException {
-            historyId.writeTo(out);
-            WritableObjects.writeLong(out, transactionId);
-        }
-
-        @Override
-        public void readExternal(final ObjectInput in) throws IOException {
-            historyId = LocalHistoryIdentifier.readFrom(in);
-            transactionId = WritableObjects.readLong(in);
-        }
-
-        private Object readResolve() {
-            return new TransactionIdentifier(historyId, transactionId);
-        }
-    }
-
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
+
     private final @NonNull LocalHistoryIdentifier historyId;
     private final long transactionId;
     private String shortString;
@@ -97,15 +58,8 @@ public final class TransactionIdentifier implements WritableIdentifier {
 
     @Override
     public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof TransactionIdentifier)) {
-            return false;
-        }
-
-        final TransactionIdentifier other = (TransactionIdentifier) obj;
-        return transactionId == other.transactionId && historyId.equals(other.historyId);
+        return this == obj || obj instanceof TransactionIdentifier other && transactionId == other.transactionId
+            && historyId.equals(other.historyId);
     }
 
     public String toShortString() {
@@ -125,7 +79,8 @@ public final class TransactionIdentifier implements WritableIdentifier {
         return toShortString();
     }
 
+    @java.io.Serial
     private Object writeReplace() {
-        return new Proxy(historyId, transactionId);
+        return new TI(this);
     }
 }