Intent API builder changes

Change-Id: I16276dc533a5f63767467d381eba45094e0b201e
diff --git a/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java b/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java
index f9f1cf1..204713e 100644
--- a/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java
+++ b/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java
@@ -15,6 +15,20 @@
  */
 package org.onosproject.calendar;
 
+import java.net.URI;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
 import org.onlab.packet.Ethernet;
 import org.onlab.rest.BaseResource;
 import org.onlab.util.Tools;
@@ -41,22 +55,11 @@
 import org.onosproject.net.resource.Bandwidth;
 import org.slf4j.Logger;
 
-import javax.ws.rs.DELETE;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Response;
-import java.net.URI;
-import java.time.Duration;
-import java.time.temporal.ChronoUnit;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
 import static org.onosproject.net.PortNumber.portNumber;
 import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
-import static org.onosproject.net.intent.IntentState.*;
+import static org.onosproject.net.intent.IntentState.FAILED;
+import static org.onosproject.net.intent.IntentState.INSTALLED;
+import static org.onosproject.net.intent.IntentState.WITHDRAWN;
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -230,15 +233,28 @@
         if (srcPort.equals("-1")) {
             HostId srcPoint = HostId.hostId(src);
             HostId dstPoint = HostId.hostId(dst);
-            return new HostToHostIntent(appId(), key, srcPoint, dstPoint,
-                                        selector, treatment, constraints,
-                                        Intent.DEFAULT_INTENT_PRIORITY);
+            return HostToHostIntent.builder()
+                    .appId(appId())
+                    .key(key)
+                    .one(srcPoint)
+                    .two(dstPoint)
+                    .selector(selector)
+                    .treatment(treatment)
+                    .constraints(constraints)
+                    .build();
+
         } else {
             ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort));
             ConnectPoint dstPoint = new ConnectPoint(deviceId(dst), portNumber(dstPort));
-            return new TwoWayP2PIntent(appId(), key, srcPoint, dstPoint,
-                                       selector, treatment, constraints,
-                                       Intent.DEFAULT_INTENT_PRIORITY);
+            return TwoWayP2PIntent.builder()
+                    .appId(appId())
+                    .key(key)
+                    .one(srcPoint)
+                    .two(dstPoint)
+                    .selector(selector)
+                    .treatment(treatment)
+                    .constraints(constraints)
+                    .build();
         }
     }
 
diff --git a/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
index 04c081b..1bad7a7 100644
--- a/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
+++ b/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
@@ -212,10 +212,14 @@
             while (!hosts.isEmpty()) {
                 Host src = hosts.remove(0);
                 for (Host dst : hosts) {
-                    HostToHostIntent intent = new HostToHostIntent(appId, src.id(), dst.id(),
-                                                                   selector, treatment,
-                                                                   constraint,
-                                                                   Intent.DEFAULT_INTENT_PRIORITY);
+                    HostToHostIntent intent = HostToHostIntent.builder()
+                            .appId(appId)
+                            .one(src.id())
+                            .two(dst.id())
+                            .selector(selector)
+                            .treatment(treatment)
+                            .constraints(constraint)
+                            .build();
                     existingIntents.add(intent);
                     intentService.submit(intent);
                 }
@@ -414,9 +418,14 @@
             public HostPair(Host src, Host dst) {
                 this.src = src;
                 this.dst = dst;
-                this.intent = new HostToHostIntent(appId, src.id(), dst.id(),
-                                                   selector, treatment, constraint,
-                                                   Intent.DEFAULT_INTENT_PRIORITY);
+                this.intent = HostToHostIntent.builder()
+                        .appId(appId)
+                        .one(src.id())
+                        .two(dst.id())
+                        .selector(selector)
+                        .treatment(treatment)
+                        .constraints(constraint)
+                        .build();
             }
 
             public HostToHostIntent h2hIntent() {
diff --git a/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java b/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java
index 4b1d85a..63e6d40 100644
--- a/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java
+++ b/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java
@@ -160,8 +160,13 @@
         TrafficSelector selector = DefaultTrafficSelector.emptySelector();
         TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
 
-        HostToHostIntent intent = new HostToHostIntent(appId, srcId, dstId,
-                                                       selector, treatment);
+        HostToHostIntent intent = HostToHostIntent.builder()
+                .appId(appId)
+                .one(srcId)
+                .two(dstId)
+                .selector(selector)
+                .treatment(treatment)
+                .build();
 
         intentService.submit(intent);
     }