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/MatchActionOperations.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperations.java
index 3aaffad..a17d0f2 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperations.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperations.java
@@ -2,8 +2,18 @@
import net.onrc.onos.api.batchoperation.BatchOperation;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * The MatchActionOperations class holds a list of MatchActionOperationEntry
+ * objects to be executed together as one set.
+ * <p/>
+ * Objects of this class are immutable.
+ */
public final class MatchActionOperations
extends BatchOperation<MatchActionOperationEntry> {
+
+ private final MatchActionOperationsId id;
/**
* The MatchAction operators.
*/
@@ -12,5 +22,47 @@
REMOVE,
}
- // TODO waiting on updated BatchOperation as of 8/7
+ /**
+ * Constructs a MatchActionOperations object from an id. Internal
+ * constructor called by a public factory method.
+ *
+ * @param newId match action operations identifier for this instance
+ */
+ private MatchActionOperations(final MatchActionOperationsId newId) {
+ id = checkNotNull(newId);
+ }
+
+ /**
+ * Creates a MatchActionOperations object from an id.
+ *
+ * @param newId match action operations identifier to use for the new object
+ * @return Match Action Operations object
+ */
+ public static MatchActionOperations createMatchActionsOperations(
+ final MatchActionOperationsId newId) {
+ return new MatchActionOperations(newId);
+ }
+
+ /**
+ * Gets the identifier for the Match Action Operations object.
+ *
+ * @return identifier for the Opertions object
+ */
+ public MatchActionOperationsId getOperationsId() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof MatchActionOperations) {
+ final MatchActionOperations other = (MatchActionOperations) obj;
+ return (id.equals(other.id));
+ }
+ return false;
+ }
}