Add static factory method to create ConnectPoints from strings.

Change-Id: I743b4a4fb433ad07cf6f2cbed3da7b6e19a74ebb
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
index cdf4a73..2939afa 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
@@ -15,15 +15,9 @@
  */
 package org.onosproject.cli.net;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
 import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
@@ -31,8 +25,9 @@
 import org.onosproject.net.intent.IntentService;
 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
 
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.PortNumber.portNumber;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * Installs connectivity intent between a single ingress device and multiple egress devices.
@@ -54,18 +49,12 @@
         }
 
         String ingressDeviceString = deviceStrings[0];
-        DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
-        PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
-        ConnectPoint ingressPoint = new ConnectPoint(ingressDeviceId,
-                                                     ingressPortNumber);
+        ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString);
 
         Set<ConnectPoint> egressPoints = new HashSet<>();
         for (int index = 1; index < deviceStrings.length; index++) {
             String egressDeviceString = deviceStrings[index];
-            DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
-            PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
-            ConnectPoint egress = new ConnectPoint(egressDeviceId,
-                                                   egressPortNumber);
+            ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
             egressPoints.add(egress);
         }
 
@@ -88,32 +77,4 @@
         print("Single point to multipoint intent submitted:\n%s", intent.toString());
     }
 
-    /**
-     * Extracts the port number portion of the ConnectPoint.
-     *
-     * @param deviceString string representing the device/port
-     * @return port number as a string, empty string if the port is not found
-     */
-    private String getPortNumber(String deviceString) {
-        int slash = deviceString.indexOf('/');
-        if (slash <= 0) {
-            return "";
-        }
-        return deviceString.substring(slash + 1, deviceString.length());
-    }
-
-    /**
-     * Extracts the device ID portion of the ConnectPoint.
-     *
-     * @param deviceString string representing the device/port
-     * @return device ID string
-     */
-    private String getDeviceId(String deviceString) {
-        int slash = deviceString.indexOf('/');
-        if (slash <= 0) {
-            return "";
-        }
-        return deviceString.substring(0, slash);
-    }
-
 }