Add copy constructor
Change-Id: If9b50a8e5db29e4bae2c93b51f34c5e043563094
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/mastership/impl/RoleValue.java b/core/store/dist/src/main/java/org/onlab/onos/store/mastership/impl/RoleValue.java
index aa5d911..a074b94 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/mastership/impl/RoleValue.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/mastership/impl/RoleValue.java
@@ -31,6 +31,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
+import com.google.common.collect.Lists;
/**
* A structure that holds node mastership roles associated with a
@@ -40,12 +41,26 @@
protected final Map<MastershipRole, List<NodeId>> value = new EnumMap<>(MastershipRole.class);
+ /**
+ * Constructs empty RoleValue.
+ */
public RoleValue() {
value.put(MastershipRole.MASTER, new LinkedList<NodeId>());
value.put(MastershipRole.STANDBY, new LinkedList<NodeId>());
value.put(MastershipRole.NONE, new LinkedList<NodeId>());
}
+ /**
+ * Constructs copy of specified RoleValue.
+ *
+ * @param original original to create copy from
+ */
+ public RoleValue(final RoleValue original) {
+ value.put(MASTER, Lists.newLinkedList(original.value.get(MASTER)));
+ value.put(STANDBY, Lists.newLinkedList(original.value.get(STANDBY)));
+ value.put(NONE, Lists.newLinkedList(original.value.get(NONE)));
+ }
+
// exposing internals for serialization purpose only
Map<MastershipRole, List<NodeId>> value() {
return Collections.unmodifiableMap(value);