Refactored primitive builders to consolidate methods into the base DistributedPrimitiveBuilder
Change-Id: I9a24117b41d1feeb5cf460c6adfa484aabcbb8c1
diff --git a/core/api/src/main/java/org/onosproject/store/service/AsyncDistributedSet.java b/core/api/src/main/java/org/onosproject/store/service/AsyncDistributedSet.java
index 251ee14..3f1a215 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AsyncDistributedSet.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AsyncDistributedSet.java
@@ -19,6 +19,8 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;
+import org.onosproject.store.primitives.DefaultDistributedSet;
+
/**
* A distributed collection designed for holding unique elements.
* <p>
@@ -122,6 +124,26 @@
*/
CompletableFuture<Boolean> removeAll(Collection<? extends E> c);
+
+ /**
+ * Returns a new {@link DistributedSet} that is backed by this instance.
+ *
+ * @return new {@code DistributedSet} instance
+ */
+ default DistributedSet<E> asDistributedSet() {
+ return asDistributedSet(DistributedPrimitive.DEFAULT_OPERTATION_TIMEOUT_MILLIS);
+ }
+
+ /**
+ * Returns a new {@link DistributedSet} that is backed by this instance.
+ *
+ * @param timeoutMillis timeout duration for the returned DistributedSet operations
+ * @return new {@code DistributedSet} instance
+ */
+ default DistributedSet<E> asDistributedSet(long timeoutMillis) {
+ return new DefaultDistributedSet<>(this, timeoutMillis);
+ }
+
/**
* Returns the entries as a immutable set. The returned set is a snapshot and will not reflect new changes made to
* this AsyncDistributedSet