Minor changes around ProtectionConstraint

- use factory
- implement toString

Change-Id: Ic30b2d3a7c2f6c65fac9b0971291d82af8ec23d7
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
index 294b75e..b2b4b82 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
@@ -25,7 +25,7 @@
 import org.onosproject.net.intent.Intent;
 import org.onosproject.net.intent.IntentService;
 import org.onosproject.net.intent.PointToPointIntent;
-import org.onosproject.net.intent.constraint.ProtectionConstraint;
+import static org.onosproject.net.intent.constraint.ProtectionConstraint.protection;
 
 import java.util.List;
 
@@ -65,7 +65,7 @@
 
         List<Constraint> constraints = buildConstraints();
         if (backup) {
-            constraints.add(new ProtectionConstraint());
+            constraints.add(protection());
         }
 
         Intent intent = PointToPointIntent.builder()
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/ProtectionConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/ProtectionConstraint.java
index d4d2c74..a337040 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/ProtectionConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/ProtectionConstraint.java
@@ -29,6 +29,8 @@
  */
 @Beta
 public class ProtectionConstraint implements Constraint {
+    private static final ProtectionConstraint PROTECTION_CONSTRAINT = new ProtectionConstraint();
+
     // doesn't use LinkResourceService
     @Override
     public double cost(Link link, ResourceContext context) {
@@ -55,4 +57,21 @@
         }
         return false;
     }
+
+    /**
+     * Returns protection constraint.
+     *
+     * @return
+     */
+    public static ProtectionConstraint protection() {
+        return PROTECTION_CONSTRAINT;
+    }
+
+    protected  ProtectionConstraint() {
+    }
+
+    @Override
+    public String toString() {
+        return "Protection";
+    }
 }