Finalize Match/Action Objects - ONOS-1728
* Added equals() and hashCode() methods to objects with IDs
* Added/Updates Javadocs
* Implemented rudimentary execute and query methods for
Operations in the MatchActionModule. Operations are preserved
but not actually executed currently.
* Implemented factories for MatchActionOperationsId and
MatchActionOperations
* Added unit tests to check creation and execution of MatchAction
* Added unit tests for new Immutable classes
Change-Id: Id865d04fd1048d00e533736c95c3052148041d95
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
index 8ea2168..7c9d1db 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
@@ -1,5 +1,62 @@
package net.onrc.onos.core.matchaction;
-public interface MatchActionOperationsId {
- // TODO waiting on MatchActionOperations
+import java.util.UUID;
+
+/**
+ * Identifier for a MatchActionOperations object. This is an immutable class
+ * that encapsulates a globally unique identifier for the MatchActionOperations
+ * object.
+ */
+public final class MatchActionOperationsId {
+
+ private static final String OPERATIONS_ID_PREFIX = "MatchActionOperationsId-";
+ private final String id;
+
+ /**
+ * Constructs an Operations identifier and allocates a unique identifier
+ * for it.
+ */
+ private MatchActionOperationsId() {
+ id = OPERATIONS_ID_PREFIX + UUID.randomUUID();
+ }
+
+ /**
+ * Gets the identifier for the Operations object.
+ *
+ * @return Operations object identifier as a string
+ */
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MatchActionOperationsId)) {
+ return false;
+ }
+
+ final MatchActionOperationsId otherMatchActionOperationsId =
+ (MatchActionOperationsId) other;
+
+ return otherMatchActionOperationsId.getId().equals(getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /**
+ * Creates a new Id for a MatchActionOperation.
+ *
+ * @return new Id for a MatchActionOperation
+ */
+ public static MatchActionOperationsId createNewOperationsId() {
+ return new MatchActionOperationsId();
+ }
+
}