Refactor Intent subsystem to eliminate using FlowRuleBatchOperation

Change-Id: Iee76dac5fa9935713ffc370b34ac47d9286ff351
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java b/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
index b29bb08..65b6314 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
@@ -17,6 +17,7 @@
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -31,9 +32,7 @@
 import org.onosproject.net.flow.DefaultFlowRule;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleBatchEntry;
-import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
-import org.onosproject.net.flow.FlowRuleBatchOperation;
+import org.onosproject.net.flow.FlowRuleOperation;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.intent.Constraint;
@@ -46,7 +45,9 @@
 import org.onosproject.net.resource.LinkResourceService;
 import org.slf4j.Logger;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -82,14 +83,14 @@
     }
 
     @Override
-    public List<FlowRuleBatchOperation> install(PathIntent intent) {
+    public List<Set<FlowRuleOperation>> install(PathIntent intent) {
         LinkResourceAllocations allocations = allocateResources(intent);
 
         TrafficSelector.Builder builder =
                 DefaultTrafficSelector.builder(intent.selector());
         Iterator<Link> links = intent.path().links().iterator();
         ConnectPoint prev = links.next().dst();
-        List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
+        Set<FlowRuleOperation> rules = Sets.newHashSet();
         // TODO Generate multiple batches
         while (links.hasNext()) {
             builder.matchInPort(prev.port());
@@ -104,23 +105,21 @@
                     appId,
                     new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)),
                     0, true);
-            rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule,
-                                             intent.id().fingerprint()));
+            rules.add(new FlowRuleOperation(rule, FlowRuleOperation.Type.ADD));
             prev = link.dst();
         }
-        //FIXME this should change to new api.
-        return Lists.newArrayList(new FlowRuleBatchOperation(rules, null, 0));
+
+        return Lists.newArrayList(ImmutableSet.of(rules));
     }
 
     @Override
-    public List<FlowRuleBatchOperation> uninstall(PathIntent intent) {
+    public List<Set<FlowRuleOperation>> uninstall(PathIntent intent) {
         deallocateResources(intent);
-
         TrafficSelector.Builder builder =
                 DefaultTrafficSelector.builder(intent.selector());
         Iterator<Link> links = intent.path().links().iterator();
         ConnectPoint prev = links.next().dst();
-        List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
+        Set<FlowRuleOperation> rules = Sets.newHashSet();
         // TODO Generate multiple batches
         while (links.hasNext()) {
             builder.matchInPort(prev.port());
@@ -133,18 +132,17 @@
                     builder.build(), treatment, 123, appId,
                     new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)),
                     0, true);
-            rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule,
-                                             intent.id().fingerprint()));
+            rules.add(new FlowRuleOperation(rule, FlowRuleOperation.Type.REMOVE));
             prev = link.dst();
         }
         // FIXME this should change to new api
-        return Lists.newArrayList(new FlowRuleBatchOperation(rules, null, 0));
+        return Lists.newArrayList(ImmutableSet.of(rules));
     }
 
     @Override
-    public List<FlowRuleBatchOperation> replace(PathIntent oldIntent, PathIntent newIntent) {
+    public List<Set<FlowRuleOperation>> replace(PathIntent oldIntent, PathIntent newIntent) {
         // FIXME: implement this
-        List<FlowRuleBatchOperation> batches = Lists.newArrayList();
+        List<Set<FlowRuleOperation>> batches = Lists.newArrayList();
         batches.addAll(uninstall(oldIntent));
         batches.addAll(install(newIntent));
         return batches;