Do not implement concepts.Builder 36/100836/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Apr 2022 09:21:44 +0000 (11:21 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Apr 2022 10:02:57 +0000 (12:02 +0200)
concepts.Builder is going away, do not implement it.

Change-Id: I1f1f8d72965225f4342c52b0602f8266109700a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestBuilder.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendHistoryMetadataBuilder.java

index b0a0cad..8e2e5cc 100644 (file)
@@ -14,20 +14,18 @@ import akka.actor.ActorRef;
 import com.google.common.annotations.Beta;
 import java.util.ArrayList;
 import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.concepts.Identifiable;
 
 /**
- * A reusable {@link Builder} for creating {@link ModifyTransactionRequest} message instances. Its internal state is
- * reset when {@link #build()} is invoked, hence it can be used to create a sequence of messages. This class is NOT
- * thread-safe.
+ * A reusable builder for creating {@link ModifyTransactionRequest} message instances. Its internal state is reset when
+ * {@link #build()} is invoked, hence it can be used to create a sequence of messages. This class is NOT thread-safe.
  *
  * @author Robert Varga
  */
 @Beta
-public final class ModifyTransactionRequestBuilder implements Builder<ModifyTransactionRequest>,
-        Identifiable<TransactionIdentifier> {
+public final class ModifyTransactionRequestBuilder implements Identifiable<TransactionIdentifier> {
     private final List<TransactionModification> modifications = new ArrayList<>(1);
     private final TransactionIdentifier identifier;
     private final ActorRef replyTo;
@@ -82,8 +80,7 @@ public final class ModifyTransactionRequestBuilder implements Builder<ModifyTran
         return modifications.size();
     }
 
-    @Override
-    public ModifyTransactionRequest build() {
+    public @NonNull ModifyTransactionRequest build() {
         checkState(haveSequence, "Request sequence has not been set");
 
         final ModifyTransactionRequest ret = new ModifyTransactionRequest(identifier, sequence, replyTo, modifications,
index 0851278..17e0a5c 100644 (file)
@@ -405,7 +405,7 @@ public class DatastoreContext implements ClientActorConfig {
         return initialPayloadSerializedBufferCapacity;
     }
 
-    public static class Builder implements org.opendaylight.yangtools.concepts.Builder<DatastoreContext> {
+    public static class Builder {
         private final DatastoreContext datastoreContext;
 
         Builder(final DatastoreContext datastoreContext) {
@@ -689,7 +689,6 @@ public class DatastoreContext implements ClientActorConfig {
             return this;
         }
 
-        @Override
         public DatastoreContext build() {
             if (datastoreContext.dataStoreName != null) {
                 GLOBAL_DATASTORE_NAMES.add(datastoreContext.dataStoreName);
index 7f281ab..e43d736 100644 (file)
@@ -24,7 +24,6 @@ import org.opendaylight.controller.cluster.datastore.persisted.FrontendClientMet
 import org.opendaylight.controller.cluster.datastore.persisted.FrontendHistoryMetadata;
 import org.opendaylight.controller.cluster.datastore.utils.ImmutableUnsignedLongSet;
 import org.opendaylight.controller.cluster.datastore.utils.MutableUnsignedLongSet;
-import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,15 +31,15 @@ import org.slf4j.LoggerFactory;
 /**
  * This class is NOT thread-safe.
  */
-abstract class FrontendClientMetadataBuilder implements Builder<FrontendClientMetadata>,
-        Identifiable<ClientIdentifier> {
+// FIXME: sealed when we have JDK17+
+abstract class FrontendClientMetadataBuilder implements Identifiable<ClientIdentifier> {
     static final class Disabled extends FrontendClientMetadataBuilder {
         Disabled(final String shardName, final ClientIdentifier identifier) {
             super(shardName, identifier);
         }
 
         @Override
-        public FrontendClientMetadata build() {
+        FrontendClientMetadata build() {
             return new FrontendClientMetadata(getIdentifier(), ImmutableUnsignedLongSet.of(), ImmutableList.of());
         }
 
@@ -119,7 +118,7 @@ abstract class FrontendClientMetadataBuilder implements Builder<FrontendClientMe
         }
 
         @Override
-        public FrontendClientMetadata build() {
+        FrontendClientMetadata build() {
             return new FrontendClientMetadata(getIdentifier(), purgedHistories.immutableCopy(),
                 Collections2.transform(currentHistories.values(), FrontendHistoryMetadataBuilder::build));
         }
@@ -289,6 +288,8 @@ abstract class FrontendClientMetadataBuilder implements Builder<FrontendClientMe
         return shardName;
     }
 
+    abstract FrontendClientMetadata build();
+
     abstract void onHistoryCreated(LocalHistoryIdentifier historyId);
 
     abstract void onHistoryClosed(LocalHistoryIdentifier historyId);
index 8a1efbb..f869e7a 100644 (file)
@@ -21,12 +21,9 @@ import org.opendaylight.controller.cluster.datastore.persisted.FrontendHistoryMe
 import org.opendaylight.controller.cluster.datastore.utils.ImmutableUnsignedLongSet;
 import org.opendaylight.controller.cluster.datastore.utils.MutableUnsignedLongSet;
 import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongBitmap;
-import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.concepts.Identifiable;
 
-final class FrontendHistoryMetadataBuilder implements Builder<FrontendHistoryMetadata>,
-        Identifiable<LocalHistoryIdentifier> {
-
+final class FrontendHistoryMetadataBuilder implements Identifiable<LocalHistoryIdentifier> {
     private final @NonNull Map<UnsignedLong, Boolean> closedTransactions;
     private final @NonNull MutableUnsignedLongSet purgedTransactions;
     private final @NonNull LocalHistoryIdentifier identifier;
@@ -51,7 +48,6 @@ final class FrontendHistoryMetadataBuilder implements Builder<FrontendHistoryMet
         return identifier;
     }
 
-    @Override
     public FrontendHistoryMetadata build() {
         return new FrontendHistoryMetadata(identifier.getHistoryId(), identifier.getCookie(), closed,
             UnsignedLongBitmap.copyOf(closedTransactions), purgedTransactions.immutableCopy());