[Cardinal] Add builders for Intents and remove extra constructors.

Starting with PointToPoint intent to see how it looks

Change-Id: I5366a05d657ceaad18c03b95cd71f5d1107200e2
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
index 9f34945..b5bc25b 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
@@ -37,7 +37,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -130,8 +129,8 @@
      * @return the intents to install
      */
     private Collection<PointToPointIntent> buildPeerIntents(
-                                                BgpSpeaker bgpSpeaker,
-                                                BgpPeer bgpPeer) {
+            BgpSpeaker bgpSpeaker,
+            BgpPeer bgpPeer) {
         List<PointToPointIntent> intents = new ArrayList<>();
 
         ConnectPoint bgpdConnectPoint = bgpSpeaker.connectPoint();
@@ -157,7 +156,7 @@
         }
         if (bgpdAddress == null) {
             log.debug("No IP address found for peer {} on interface {}",
-                      bgpPeer, bgpPeer.connectPoint());
+                    bgpPeer, bgpPeer.connectPoint());
             return intents;
         }
 
@@ -185,83 +184,101 @@
 
         // Path from BGP speaker to BGP peer matching destination TCP port 179
         selector = buildSelector(tcpProtocol,
-                                 bgpdAddress,
-                                 bgpdPeerAddress,
-                                 null,
-                                 BGP_PORT);
+                bgpdAddress,
+                bgpdPeerAddress,
+                null,
+                BGP_PORT);
 
         int priority = PRIORITY_OFFSET;
 
-        intents.add(new PointToPointIntent(appId, selector, treatment,
-                                           bgpdConnectPoint,
-                                           bgpdPeerConnectPoint,
-                                           Collections.emptyList(),
-                                           priority));
+        intents.add(PointToPointIntent.builder()
+                .appId(appId)
+                .selector(selector)
+                .treatment(treatment)
+                .ingressPoint(bgpdConnectPoint)
+                .egressPoint(bgpdPeerConnectPoint)
+                .priority(priority)
+                .build());
 
         // Path from BGP speaker to BGP peer matching source TCP port 179
         selector = buildSelector(tcpProtocol,
-                                 bgpdAddress,
-                                 bgpdPeerAddress,
-                                 BGP_PORT,
-                                 null);
+                bgpdAddress,
+                bgpdPeerAddress,
+                BGP_PORT,
+                null);
 
-        intents.add(new PointToPointIntent(appId, selector, treatment,
-                                           bgpdConnectPoint,
-                                           bgpdPeerConnectPoint,
-                                           Collections.emptyList(),
-                                           priority));
+        intents.add(PointToPointIntent.builder()
+                .appId(appId)
+                .selector(selector)
+                .treatment(treatment)
+                .ingressPoint(bgpdConnectPoint)
+                .egressPoint(bgpdPeerConnectPoint)
+                .priority(priority)
+                .build());
 
         // Path from BGP peer to BGP speaker matching destination TCP port 179
         selector = buildSelector(tcpProtocol,
-                                 bgpdPeerAddress,
-                                 bgpdAddress,
-                                 null,
-                                 BGP_PORT);
+                bgpdPeerAddress,
+                bgpdAddress,
+                null,
+                BGP_PORT);
 
-        intents.add(new PointToPointIntent(appId, selector, treatment,
-                                           bgpdPeerConnectPoint,
-                                           bgpdConnectPoint,
-                                           Collections.emptyList(),
-                                           priority));
+        intents.add(PointToPointIntent.builder()
+                .appId(appId)
+                .selector(selector)
+                .treatment(treatment)
+                .ingressPoint(bgpdPeerConnectPoint)
+                .egressPoint(bgpdConnectPoint)
+                .priority(priority)
+                .build());
 
         // Path from BGP peer to BGP speaker matching source TCP port 179
         selector = buildSelector(tcpProtocol,
-                                 bgpdPeerAddress,
-                                 bgpdAddress,
-                                 BGP_PORT,
-                                 null);
+                bgpdPeerAddress,
+                bgpdAddress,
+                BGP_PORT,
+                null);
 
-        intents.add(new PointToPointIntent(appId, selector, treatment,
-                                           bgpdPeerConnectPoint,
-                                           bgpdConnectPoint,
-                                           Collections.emptyList(),
-                                           priority));
+        intents.add(PointToPointIntent.builder()
+                .appId(appId)
+                .selector(selector)
+                .treatment(treatment)
+                .ingressPoint(bgpdPeerConnectPoint)
+                .egressPoint(bgpdConnectPoint)
+                .priority(priority)
+                .build());
 
         // ICMP path from BGP speaker to BGP peer
         selector = buildSelector(icmpProtocol,
-                                 bgpdAddress,
-                                 bgpdPeerAddress,
-                                 null,
-                                 null);
+                bgpdAddress,
+                bgpdPeerAddress,
+                null,
+                null);
 
-        intents.add(new PointToPointIntent(appId, selector, treatment,
-                                           bgpdConnectPoint,
-                                           bgpdPeerConnectPoint,
-                                           Collections.emptyList(),
-                                           priority));
+        intents.add(PointToPointIntent.builder()
+                .appId(appId)
+                .selector(selector)
+                .treatment(treatment)
+                .ingressPoint(bgpdConnectPoint)
+                .egressPoint(bgpdPeerConnectPoint)
+                .priority(priority)
+                .build());
 
         // ICMP path from BGP peer to BGP speaker
         selector = buildSelector(icmpProtocol,
-                                 bgpdPeerAddress,
-                                 bgpdAddress,
-                                 null,
-                                 null);
+                bgpdPeerAddress,
+                bgpdAddress,
+                null,
+                null);
 
-        intents.add(new PointToPointIntent(appId, selector, treatment,
-                                           bgpdPeerConnectPoint,
-                                           bgpdConnectPoint,
-                                           Collections.emptyList(),
-                                           priority));
+        intents.add(PointToPointIntent.builder()
+                .appId(appId)
+                .selector(selector)
+                .treatment(treatment)
+                .ingressPoint(bgpdPeerConnectPoint)
+                .egressPoint(bgpdConnectPoint)
+                .priority(priority)
+                .build());
 
         return intents;
     }
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
index 7ec843b..f16c8de 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
@@ -15,7 +15,13 @@
  */
 package org.onosproject.sdnip;
 
-import com.google.common.collect.Sets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -46,14 +52,13 @@
 import org.onosproject.routing.config.InterfaceAddress;
 import org.onosproject.routing.config.RoutingConfigurationService;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.Sets;
 
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
 import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
 
 /**
@@ -285,9 +290,13 @@
             builder.matchTcpDst(dstTcpPort);
         }
 
-        PointToPointIntent intent = new PointToPointIntent(
-                APPID, builder.build(), noTreatment,
-                srcConnectPoint, dstConnectPoint);
+        PointToPointIntent intent = PointToPointIntent.builder()
+                .appId(APPID)
+                .selector(builder.build())
+                .treatment(noTreatment)
+                .ingressPoint(srcConnectPoint)
+                .egressPoint(dstConnectPoint)
+                .build();
 
         intentList.add(intent);
     }
@@ -457,9 +466,13 @@
                 .matchIPDst(IpPrefix.valueOf(dstPrefix))
                 .build();
 
-        PointToPointIntent intent = new PointToPointIntent(
-                APPID, selector, noTreatment,
-                srcConnectPoint, dstConnectPoint);
+        PointToPointIntent intent = PointToPointIntent.builder()
+                .appId(APPID)
+                .selector(selector)
+                .treatment(noTreatment)
+                .ingressPoint(srcConnectPoint)
+                .egressPoint(dstConnectPoint)
+                .build();
 
         intentList.add(intent);
     }