Remove mutating methods in IntentData
Change-Id: I1d9ac694922f4a12b2d94a92b64be2c336c31ae3
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
index c3277bc..743e349 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
@@ -68,6 +68,27 @@
}
/**
+ * Creates a new intent data object.
+ *
+ * @param intent intent this metadata references
+ * @param state intent state
+ * @param version version of the intent for this key
+ * @param origin ID of the node where the data was originally created
+ */
+ public IntentData(Intent intent, IntentState state, Timestamp version, NodeId origin) {
+ checkNotNull(intent);
+ checkNotNull(state);
+ checkNotNull(version);
+ checkNotNull(origin);
+
+ this.intent = intent;
+ this.state = state;
+ this.request = state;
+ this.version = version;
+ this.origin = origin;
+ }
+
+ /**
* Copy constructor.
*
* @param intentData intent data to copy
@@ -84,6 +105,18 @@
errorCount = intentData.errorCount;
}
+ /**
+ * Create a new instance based on the original instance with new installables.
+ *
+ * @param original original data
+ * @param installables new installable intents to set
+ */
+ public IntentData(IntentData original, List<Intent> installables) {
+ this(original);
+
+ this.installables = ImmutableList.copyOf(checkNotNull(installables));
+ }
+
// kryo constructor
protected IntentData() {
intent = null;
@@ -131,15 +164,6 @@
}
/**
- * Sets the origin, which is the node that created the intent.
- *
- * @param origin origin instance
- */
- public void setOrigin(NodeId origin) {
- this.origin = origin;
- }
-
- /**
* Returns the origin node that created this intent.
*
* @return origin node ID
@@ -158,20 +182,6 @@
}
/**
- * Sets the version for this intent data.
- * <p>
- * The store should call this method only once when the IntentData is
- * first passed into the pending map. Ideally, an IntentData is timestamped
- * on the same thread that the called used to submit the intents.
- * </p>
- *
- * @param version the version/timestamp for this intent data
- */
- public void setVersion(Timestamp version) {
- this.version = version;
- }
-
- /**
* Increments the error count for this intent.
*/
public void incrementErrorCount() {
@@ -198,15 +208,6 @@
}
/**
- * Sets the intent installables to the given list of intents.
- *
- * @param installables list of installables for this intent
- */
- public void setInstallables(List<Intent> installables) {
- this.installables = ImmutableList.copyOf(installables);
- }
-
- /**
* Returns the installables associated with this intent.
*
* @return list of installable intents