Yuta HIGUCHI
Committed by Gerrit Code Review

Minor changes around ProtectionConstraint

- use factory
- implement toString

Change-Id: Ic30b2d3a7c2f6c65fac9b0971291d82af8ec23d7
......@@ -25,7 +25,7 @@ import org.onosproject.net.intent.Constraint;
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 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand {
List<Constraint> constraints = buildConstraints();
if (backup) {
constraints.add(new ProtectionConstraint());
constraints.add(protection());
}
Intent intent = PointToPointIntent.builder()
......
......@@ -29,6 +29,8 @@ import org.onosproject.net.intent.ResourceContext;
*/
@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 @@ public class ProtectionConstraint implements Constraint {
}
return false;
}
/**
* Returns protection constraint.
*
* @return
*/
public static ProtectionConstraint protection() {
return PROTECTION_CONSTRAINT;
}
protected ProtectionConstraint() {
}
@Override
public String toString() {
return "Protection";
}
}
......