Improvements to flows list command.
* Added -s option which gives more succinct output.
* Display each flow on one line for easy grepping.
* Added ability to filter output by table ID.
* Flows are now sorted by descending priority within a table.
* Removed the use of toStringHelper in instructions and criterion to produce
less verbose output.
Change-Id: I1c874c776491386488ea5a4d23627b20f1e5728b
diff --git a/cli/src/main/java/org/onosproject/cli/Comparators.java b/cli/src/main/java/org/onosproject/cli/Comparators.java
index 03d25ce..50e79a1 100644
--- a/cli/src/main/java/org/onosproject/cli/Comparators.java
+++ b/cli/src/main/java/org/onosproject/cli/Comparators.java
@@ -71,10 +71,16 @@
public static final Comparator<FlowRule> FLOW_RULE_COMPARATOR = new Comparator<FlowRule>() {
@Override
public int compare(FlowRule f1, FlowRule f2) {
- int tableCompare = Integer.valueOf(f1.tableId()).compareTo(f2.tableId());
- return (tableCompare == 0)
+ // Compare table IDs in ascending order
+ int tableCompare = f1.tableId() - f2.tableId();
+ if (tableCompare != 0) {
+ return tableCompare;
+ }
+ // Compare priorities in descending order
+ int priorityCompare = f2.priority() - f1.priority();
+ return (priorityCompare == 0)
? Long.valueOf(f1.id().value()).compareTo(f2.id().value())
- : tableCompare;
+ : priorityCompare;
}
};