[SDFAB-90] Implement priority mechanism in the Policy framework.
Change-Id: I738956566bfcf1bd5e2d4fcd9bfef153b5fb674a
diff --git a/api/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java b/api/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java
index 83098fe..bcad3bd 100644
--- a/api/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java
+++ b/api/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java
@@ -34,17 +34,34 @@
private TrafficMatchId trafficMatchId;
private TrafficSelector trafficSelector;
private PolicyId policyId;
+ private TrafficMatchPriority trafficMatchPriority;
/**
* Builds a traffic match.
*
- * @param trafficselector the traffic selector
- * @param policyid the associated policy id
+ * @param trafficSelector the traffic selector
+ * @param policyId the associated policy id
+ * @deprecated in version 3.0.2
*/
- public TrafficMatch(TrafficSelector trafficselector, PolicyId policyid) {
- trafficSelector = trafficselector;
- trafficMatchId = TrafficMatchId.trafficMatchId(computeTrafficMatchId());
- policyId = policyid;
+ public TrafficMatch(TrafficSelector trafficSelector, PolicyId policyId) {
+ this.trafficSelector = trafficSelector;
+ this.trafficMatchId = TrafficMatchId.trafficMatchId(computeTrafficMatchId());
+ this.policyId = policyId;
+ this.trafficMatchPriority = new TrafficMatchPriority(PolicyService.TRAFFIC_MATCH_PRIORITY);
+ }
+
+ /**
+ * Builds a traffic match.
+ *
+ * @param trafficSelector the traffic selector
+ * @param policyId the associated policy id
+ * @param trafficMatchPriority the priority
+ */
+ public TrafficMatch(TrafficSelector trafficSelector, PolicyId policyId, TrafficMatchPriority trafficMatchPriority) {
+ this.trafficSelector = trafficSelector;
+ this.trafficMatchId = TrafficMatchId.trafficMatchId(computeTrafficMatchId());
+ this.policyId = policyId;
+ this.trafficMatchPriority = trafficMatchPriority;
}
/**
@@ -74,9 +91,18 @@
return trafficSelector;
}
+ /**
+ * Returns the priority.
+ *
+ * @return the priority
+ */
+ public TrafficMatchPriority trafficMatchPriority() {
+ return trafficMatchPriority;
+ }
+
@Override
public int hashCode() {
- return Objects.hash(trafficMatchId, trafficSelector, policyId);
+ return Objects.hash(trafficMatchId, trafficSelector, policyId, trafficMatchPriority);
}
@Override
@@ -88,7 +114,8 @@
final TrafficMatch other = (TrafficMatch) obj;
return Objects.equals(this.trafficMatchId, other.trafficMatchId) &&
Objects.equals(trafficSelector, other.trafficSelector) &&
- Objects.equals(policyId, other.policyId);
+ Objects.equals(policyId, other.policyId) &&
+ Objects.equals(trafficMatchPriority, other.trafficMatchPriority);
}
return false;
}
@@ -99,6 +126,7 @@
.add("trafficMatchId", trafficMatchId)
.add("trafficSelector", trafficSelector)
.add("policyId", policyId)
+ .add("trafficMatchPriority", trafficMatchPriority)
.toString();
}