use of org.onosproject.net.intent.constraint.WaypointConstraint in project onos by opennetworkinglab.
the class IntentJsonMatcher method matchWaypointConstraint.
/**
* Matches a waypoint constraint against a JSON representation of the
* constraint.
*
* @param waypointConstraint constraint object to match
* @param constraintJson JSON representation of the constraint
* @return true if the constraint and JSON match, false otherwise.
*/
private boolean matchWaypointConstraint(WaypointConstraint waypointConstraint, JsonNode constraintJson) {
final JsonNode waypointsJson = constraintJson.get("waypoints");
if (waypointsJson.size() != waypointConstraint.waypoints().size()) {
return false;
}
for (int waypointsIndex = 0; waypointsIndex < waypointsJson.size(); waypointsIndex++) {
boolean waypointFound = false;
final String waypointJson = waypointsJson.get(waypointsIndex).asText();
for (DeviceId waypoint : waypointConstraint.waypoints()) {
if (waypoint.toString().equals(waypointJson)) {
waypointFound = true;
}
}
if (!waypointFound) {
return false;
}
}
return true;
}
Aggregations