Remove deprecated Flow Rule constructors

Change-Id: I2a078cbfbeb9db4a04ef1c59acde2fb45672a3cf
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
index 8eaaa32..f7e7708 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
@@ -18,7 +18,6 @@
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static org.slf4j.LoggerFactory.getLogger;
 
-import org.onosproject.net.DeviceId;
 import org.slf4j.Logger;
 
 public class DefaultFlowEntry extends DefaultFlowRule
@@ -37,21 +36,6 @@
 
     private final int errCode;
 
-
-    public DefaultFlowEntry(DeviceId deviceId, TrafficSelector selector,
-            TrafficTreatment treatment, int priority, FlowEntryState state,
-            long life, long packets, long bytes, long flowId,
-            int timeout) {
-        super(deviceId, selector, treatment, priority, flowId, timeout, false);
-        this.state = state;
-        this.life = life;
-        this.packets = packets;
-        this.bytes = bytes;
-        this.errCode = -1;
-        this.errType = -1;
-        this.lastSeen = System.currentTimeMillis();
-    }
-
     public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
             long life, long packets, long bytes) {
         super(rule);
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index 5a68887..293f12f 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -45,119 +45,6 @@
     private final Integer tableId;
     private final FlowRuleExtPayLoad payLoad;
 
-    @Deprecated
-    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority,
-                           long flowId, int timeout, boolean permanent) {
-        this.deviceId = deviceId;
-        this.priority = priority;
-        this.selector = selector;
-        this.treatment = treatment;
-        this.timeout = timeout;
-        this.permanent = permanent;
-        this.created = System.currentTimeMillis();
-
-        this.appId = (short) (flowId >>> 48);
-        this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
-        this.id = FlowId.valueOf(flowId);
-        this.tableId = 0;
-        this.payLoad = null;
-    }
-
-    @Deprecated
-    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority,
-                           long flowId, int timeout, boolean permanent,
-                           Type tableType) {
-        this.deviceId = deviceId;
-        this.priority = priority;
-        this.selector = selector;
-        this.treatment = treatment;
-        this.timeout = timeout;
-        this.permanent = permanent;
-        this.created = System.currentTimeMillis();
-
-        this.appId = (short) (flowId >>> 48);
-        this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
-        this.id = FlowId.valueOf(flowId);
-        this.tableId = tableType.ordinal();
-
-        this.payLoad = null;
-    }
-
-    @Deprecated
-    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority,
-                           ApplicationId appId, int timeout, boolean permanent) {
-        this(deviceId, selector, treatment, priority, appId,
-             new DefaultGroupId(0), timeout, permanent);
-    }
-
-    @Deprecated
-    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority,
-                           ApplicationId appId, int timeout, boolean permanent,
-                           Type type) {
-
-        if (priority < FlowRule.MIN_PRIORITY) {
-            throw new IllegalArgumentException("Priority cannot be less than "
-                    + MIN_PRIORITY);
-        }
-
-        this.deviceId = deviceId;
-        this.priority = priority;
-        this.selector = selector;
-        this.treatment = treatment;
-        this.appId = appId.id();
-        this.groupId = new DefaultGroupId(0);
-        this.timeout = timeout;
-        this.permanent = permanent;
-        this.created = System.currentTimeMillis();
-        this.tableId = type.ordinal();
-
-        this.payLoad = null;
-        /*
-         * id consists of the following. | appId (16 bits) | groupId (16 bits) |
-         * flowId (32 bits) |
-         */
-        this.id = FlowId.valueOf((((long) this.appId) << 48)
-                | (((long) this.groupId.id()) << 32)
-                | (this.hash() & 0xffffffffL));
-
-    }
-
-    @Deprecated
-    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority,
-                           ApplicationId appId, GroupId groupId, int timeout,
-                           boolean permanent) {
-
-        if (priority < FlowRule.MIN_PRIORITY) {
-            throw new IllegalArgumentException("Priority cannot be less than "
-                    + MIN_PRIORITY);
-        }
-
-        this.deviceId = deviceId;
-        this.priority = priority;
-        this.selector = selector;
-        this.treatment = treatment;
-        this.appId = appId.id();
-        this.groupId = groupId;
-        this.timeout = timeout;
-        this.permanent = permanent;
-        this.created = System.currentTimeMillis();
-        this.tableId = 0;
-        this.payLoad = null;
-
-        /*
-         * id consists of the following. | appId (16 bits) | groupId (16 bits) |
-         * flowId (32 bits) |
-         */
-        this.id = FlowId.valueOf((((long) this.appId) << 48)
-                | (((long) this.groupId.id()) << 32)
-                | (this.hash() & 0xffffffffL));
-    }
-
     public DefaultFlowRule(FlowRule rule) {
         this.deviceId = rule.deviceId();
         this.priority = rule.priority();
@@ -371,7 +258,7 @@
                 .add("treatment", treatment == null ? "N/A" : treatment.allInstructions())
                 .add("tableId", tableId)
                 .add("created", created)
-                .add("payLoad", payLoad).toString()
+                .add("payLoad", payLoad)
                 .toString();
     }
 
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java
index f8dc27a..412acb6 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java
@@ -37,16 +37,17 @@
             new IntentTestsMocks.MockTreatment();
 
     private static DefaultFlowEntry makeFlowEntry(int uniqueValue) {
-        return new DefaultFlowEntry(did("id" + Integer.toString(uniqueValue)),
-                SELECTOR,
-                TREATMENT,
-                uniqueValue,
-                FlowEntry.FlowEntryState.ADDED,
-                uniqueValue,
-                uniqueValue,
-                uniqueValue,
-                uniqueValue,
-                uniqueValue);
+        FlowRule rule = DefaultFlowRule.builder()
+                .forDevice(did("id" + Integer.toString(uniqueValue)))
+                .withSelector(SELECTOR)
+                .withTreatment(TREATMENT)
+                .withPriority(uniqueValue)
+                .withCookie(uniqueValue)
+                .makeTemporary(uniqueValue)
+                .build();
+
+        return new DefaultFlowEntry(rule, FlowEntry.FlowEntryState.ADDED,
+                uniqueValue, uniqueValue, uniqueValue);
     }
 
     final DefaultFlowEntry defaultFlowEntry1 = makeFlowEntry(1);
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
index 7ad8f70..62acd16 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
@@ -41,10 +41,8 @@
     private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
     final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
     final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
-    final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2, payLoad);
     final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1);
     final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1);
-    final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2);
 
     /**
      * Checks that the DefaultFlowRule class is immutable but can be inherited
@@ -84,14 +82,20 @@
     /**
      * Tests creation of a DefaultFlowRule using a FlowId constructor.
      */
+
     @Test
     public void testCreationWithFlowId() {
-        final DefaultFlowRule rule =
-                new DefaultFlowRule(did("1"), SELECTOR,
-                        TREATMENT, 22, 33,
-                44, false);
+        final FlowRule rule =
+                DefaultFlowRule.builder()
+                .forDevice(did("1"))
+                .withSelector(SELECTOR)
+                .withTreatment(TREATMENT)
+                .withPriority(22)
+                .makeTemporary(44)
+                .fromApp(APP_ID)
+                .build();
+
         assertThat(rule.deviceId(), is(did("1")));
-        assertThat(rule.id().value(), is(33L));
         assertThat(rule.isPermanent(), is(false));
         assertThat(rule.priority(), is(22));
         assertThat(rule.selector(), is(SELECTOR));
@@ -99,6 +103,7 @@
         assertThat(rule.timeout(), is(44));
     }
 
+
     /**
      * Tests creation of a DefaultFlowRule using a PayLoad constructor.
      */
@@ -136,10 +141,16 @@
      */
     @Test
     public void testCreationWithAppId() {
-        final DefaultFlowRule rule =
-                new DefaultFlowRule(did("1"), SELECTOR,
-                        TREATMENT, 22, APP_ID,
-                        44, false);
+        final FlowRule rule =
+                DefaultFlowRule.builder()
+                        .forDevice(did("1"))
+                        .withSelector(SELECTOR)
+                        .withTreatment(TREATMENT)
+                        .withPriority(22)
+                        .fromApp(APP_ID)
+                        .makeTemporary(44)
+                        .build();
+
         assertThat(rule.deviceId(), is(did("1")));
         assertThat(rule.isPermanent(), is(false));
         assertThat(rule.priority(), is(22));