Start of interfaces for Match/Action framework

Change-Id: I1de54257b583986e6a9d93a395cb8e648235b2bf
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java b/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java
index b1d224e..7c3a22d 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java
@@ -10,7 +10,7 @@
 /**
  * A filter and actions for traffic.
  */
-public class MatchAction implements BatchOperationTarget {
+public final class MatchAction implements BatchOperationTarget {
     private final MatchActionId id;
     private final SwitchPort port;
     private final Match match;
@@ -20,7 +20,7 @@
      * Constructor.
      *
      * @param id ID for this MatchAction object
-     * @param port switch DPID
+     * @param port switch port to apply changes to
      * @param match the Match object as match condition on the port
      * @param actions the list of Action objects as actions on the switch
      */
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionEvent.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionEvent.java
new file mode 100644
index 0000000..a711d46
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionEvent.java
@@ -0,0 +1,31 @@
+package net.onrc.onos.core.matchaction;
+
+/**
+ * A MatchAction-related event.
+ *
+ * The TODO entry removed by switch or preempted by another request.
+ *
+ */
+public interface MatchActionEvent {
+
+    /**
+     * TODO.
+     *
+     * @return
+     */
+    public MatchActionId getId();
+
+    /**
+     * TODO.
+     *
+     * @return
+     */
+    public MatchActionStatus getStatus();
+
+    /**
+     * Returns the time at which the event was created.
+     *
+     * @return the time in milliseconds since start of epoch
+     */
+    long getTime();
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java
index 86e7000..3e485af 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java
@@ -2,7 +2,7 @@
 
 import net.onrc.onos.api.batchoperation.BatchOperationTarget;
 
-public class MatchActionId implements BatchOperationTarget {
+public final class MatchActionId implements BatchOperationTarget {
     private final String value;
 
     public MatchActionId(String id) {
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionListener.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionListener.java
new file mode 100644
index 0000000..20ad681
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionListener.java
@@ -0,0 +1,26 @@
+package net.onrc.onos.core.matchaction;
+
+import java.util.EventListener;
+
+/**
+ * The listener for MatchActionEvents and MatchActionOperationsEvents.
+ * <p>
+ * Callers of the MatchActionService should implement both types of listeners to
+ * receive updates to asynchronous calls.
+ */
+public interface MatchActionListener extends EventListener {
+
+    /**
+     * Processes the MatchActionOperationsEvent.
+     *
+     * @param event the event
+     */
+    public void opertaionsUpdated(MatchActionOperationsEvent event);
+
+    /**
+     * Processes the MatchActionEvent.
+     *
+     * @param event the event
+     */
+    public void matchActionUpdated(MatchActionEvent event);
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
index 2630879..557932e 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -1,8 +1,7 @@
 package net.onrc.onos.core.matchaction;
 
-import java.util.Collection;
 import java.util.EventListener;
-
+import java.util.Set;
 import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
 
 /**
@@ -14,30 +13,17 @@
 
     @Override
     public boolean addMatchAction(MatchAction matchAction) {
-        MatchActionPhase phase = new MatchActionPhase();
-        phase.addAddOperation(matchAction);
-        MatchActionPlan plan = new MatchActionPlan();
-        plan.addPhase(phase);
-        return executePlan(plan);
+        return false;
     }
 
     @Override
-    public boolean removeMatchAction(MatchActionId id) {
-        MatchActionPhase phase = new MatchActionPhase();
-        phase.addRemoveOperation(id);
-        MatchActionPlan plan = new MatchActionPlan();
-        plan.addPhase(phase);
-        return executePlan(plan);
-    }
-
-    @Override
-    public Collection<MatchAction> getMatchActions() {
+    public Set<MatchAction> getMatchActions() {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public boolean executePlan(MatchActionPlan plan) {
+    public boolean executeOperations(final MatchActionOperations operations) {
         // TODO Auto-generated method stub
         return false;
     }
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationEntry.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationEntry.java
new file mode 100644
index 0000000..b8e150b
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationEntry.java
@@ -0,0 +1,27 @@
+package net.onrc.onos.core.matchaction;
+
+import net.onrc.onos.api.batchoperation.BatchOperationEntry;
+
+public final class MatchActionOperationEntry
+       extends BatchOperationEntry<MatchActionOperations.Operator, MatchAction> {
+
+    /**
+     * Default constructor for serializer.
+     */
+    @SuppressWarnings("unused")
+    @Deprecated
+    protected MatchActionOperationEntry() {
+        super(null, null);
+    }
+
+    /**
+     * Constructs new instance for the entry of the BatchOperation.
+     *
+     * @param operator the operator of this operation
+     * @param target the target object of this operation
+     */
+    public MatchActionOperationEntry(final MatchActionOperations.Operator operator,
+                                     final MatchAction target) {
+        super(operator, target);
+    }
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperations.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperations.java
new file mode 100644
index 0000000..3aaffad
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperations.java
@@ -0,0 +1,16 @@
+package net.onrc.onos.core.matchaction;
+
+import net.onrc.onos.api.batchoperation.BatchOperation;
+
+public final class MatchActionOperations
+        extends BatchOperation<MatchActionOperationEntry> {
+    /**
+     * The MatchAction operators.
+     */
+    public enum Operator {
+        ADD,
+        REMOVE,
+    }
+
+    // TODO waiting on updated BatchOperation as of 8/7
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsEvent.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsEvent.java
new file mode 100644
index 0000000..fd8acfc
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsEvent.java
@@ -0,0 +1,28 @@
+package net.onrc.onos.core.matchaction;
+
+/**
+ * TODO.
+ */
+public interface MatchActionOperationsEvent {
+
+    /**
+     * TODO.
+     *
+     * @return
+     */
+    public MatchActionOperationsId getId();
+
+    /**
+     * TODO.
+     *
+     * @return
+     */
+    public MatchActionOperationsState getState();
+
+    /**
+     * Returns the time at which the event was created.
+     *
+     * @return the time in milliseconds since start of epoch
+     */
+    long getTime();
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
new file mode 100644
index 0000000..8ea2168
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
@@ -0,0 +1,5 @@
+package net.onrc.onos.core.matchaction;
+
+public interface MatchActionOperationsId {
+    // TODO waiting on MatchActionOperations
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsState.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsState.java
new file mode 100644
index 0000000..4239027
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsState.java
@@ -0,0 +1,5 @@
+package net.onrc.onos.core.matchaction;
+
+public interface MatchActionOperationsState {
+    // TODO waiting on MatchActionOperations
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionPhase.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionPhase.java
deleted file mode 100644
index 9350cfb..0000000
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionPhase.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package net.onrc.onos.core.matchaction;
-
-import net.onrc.onos.api.batchoperation.BatchOperation;
-import net.onrc.onos.api.batchoperation.BatchOperationEntry;
-
-public class MatchActionPhase extends
-        BatchOperation<BatchOperationEntry<MatchActionPhase.Operator, ?>> {
-    /**
-     * The MatchAction operators.
-     */
-    public enum Operator {
-        ADD,
-        REMOVE,
-    }
-
-    /**
-     * Adds an add-operation.
-     *
-     * @param matchAction match-action object to be added
-     * @return the MatchActionPhase object if succeeded, null otherwise
-     */
-    public MatchActionPhase addAddOperation(MatchAction matchAction) {
-        return (null == super.addOperation(
-                new BatchOperationEntry<Operator, MatchAction>(
-                        Operator.ADD, matchAction)))
-                ? null : this;
-    }
-
-    /**
-     * Adds a remove-operation.
-     *
-     * @param id the ID of the match-action object to be removed
-     * @return the MatchActionPhase object if succeeded, null otherwise
-     */
-    public MatchActionPhase addRemoveOperation(MatchActionId id) {
-        return (null == super.addOperation(
-                new BatchOperationEntry<Operator, MatchActionId>(
-                        Operator.REMOVE, id)))
-                ? null : this;
-    }
-
-}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionPlan.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionPlan.java
index 63f6636..2ca52be 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionPlan.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionPlan.java
@@ -11,7 +11,7 @@
  * match-actions.
  */
 public class MatchActionPlan {
-    List<MatchActionPhase> phases;
+    List<MatchAction> phases;
 
     /**
      * Constructor.
@@ -26,7 +26,7 @@
      * @param phase The batch operation of match-actions to be added to the
      *        plan.
      */
-    public void addPhase(MatchActionPhase phase) {
+    public void addPhase(MatchAction phase) {
         phases.add(phase);
     }
 
@@ -35,7 +35,7 @@
      *
      * @return The list of phases, batch operations of match-actions.
      */
-    public List<MatchActionPhase> getPhases() {
+    public List<MatchAction> getPhases() {
         return Collections.unmodifiableList(phases);
     }
 }
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionService.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionService.java
index 02a7ef3..a905e09 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionService.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionService.java
@@ -1,7 +1,7 @@
 package net.onrc.onos.core.matchaction;
 
-import java.util.Collection;
 import java.util.EventListener;
+import java.util.Set;
 
 import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
 
@@ -18,27 +18,19 @@
     boolean addMatchAction(MatchAction matchAction);
 
     /**
-     * Removes the existing match-action entry.
-     *
-     * @param id ID for MatchaAction object to be removed.
-     * @return true if succeeded, false otherwise.
-     */
-    boolean removeMatchAction(MatchActionId id);
-
-    /**
      * Gets the set of match-action entries.
      *
      * @return The set of match-action entries.
      */
-    Collection<MatchAction> getMatchActions();
+    Set<MatchAction> getMatchActions();
 
     /**
      * Executes match-action operation plan.
      *
-     * @param plan MatchActionPlan to be executed.
+     * @param operations Operations to be executed.
      * @return true if succeeded, false otherwise.
      */
-    boolean executePlan(MatchActionPlan plan);
+    boolean executeOperations(MatchActionOperations operations);
 
     /**
      * Sets a conflict detection policy.
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionStatus.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionStatus.java
new file mode 100644
index 0000000..0a7c145
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionStatus.java
@@ -0,0 +1,5 @@
+package net.onrc.onos.core.matchaction;
+
+public interface MatchActionStatus {
+
+}