Use count methods when printing simple flow rule counts via CLI

Change-Id: I2444b0ad913b0bab82b6fe642c89114322d5194b
(cherry picked from commit ca12103eed8b7407a849f7ac09b735bb4ee250bf)
diff --git a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
index 331431a..5c26b06 100644
--- a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
@@ -119,6 +119,18 @@
 
         compilePredicate();
 
+        if (countOnly && !suppressCoreOutput && filter.isEmpty() && remove == null) {
+            if (uri == null) {
+                deviceService.getDevices().forEach(device -> printCount(device, service));
+            } else {
+                Device device = deviceService.getDevice(DeviceId.deviceId(uri));
+                if (device != null) {
+                    printCount(device, service);
+                }
+            }
+            return;
+        }
+
         SortedMap<Device, List<FlowEntry>> flows = getSortedFlows(deviceService, service, coreService);
 
         // Remove flows
@@ -278,6 +290,10 @@
                 filter(f -> contentFilter.filter(f)).collect(Collectors.toList());
     }
 
+    private void printCount(Device device, FlowRuleService flowRuleService) {
+        print("deviceId=%s, flowRuleCount=%d", device.id(), flowRuleService.getFlowRuleCount(device.id()));
+    }
+
     /**
      * Prints flows.
      *