Add getMeters method for obtaining meter collection by device id

Change-Id: Ie5137ef8acce7643a58c2faa00b7027e3b9f38fa
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterService.java b/core/api/src/main/java/org/onosproject/net/meter/MeterService.java
index 2e07cb6..bb9a84b 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/MeterService.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterService.java
@@ -60,4 +60,11 @@
      */
     Collection<Meter> getAllMeters();
 
+    /**
+     * Fetches the meters by the device id.
+     *
+     * @param deviceId a device id
+     * @return a collection of meters
+     */
+    Collection<Meter> getMeters(DeviceId deviceId);
 }
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/MeterManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/MeterManager.java
index 5c5c11c..793b636 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/MeterManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/MeterManager.java
@@ -23,6 +23,7 @@
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.util.TriConsumer;
+import org.onosproject.net.DeviceId;
 import org.onosproject.net.meter.DefaultMeter;
 import org.onosproject.net.meter.Meter;
 import org.onosproject.net.meter.MeterEvent;
@@ -40,7 +41,6 @@
 import org.onosproject.net.meter.MeterStore;
 import org.onosproject.net.meter.MeterStoreDelegate;
 import org.onosproject.net.meter.MeterStoreResult;
-import org.onosproject.net.DeviceId;
 import org.onosproject.net.provider.AbstractListenerProviderRegistry;
 import org.onosproject.net.provider.AbstractProviderService;
 import org.onosproject.store.service.AtomicCounter;
@@ -160,6 +160,12 @@
     }
 
     @Override
+    public Collection<Meter> getMeters(DeviceId deviceId) {
+        return store.getAllMeters().stream().filter(m ->
+                m.deviceId().equals(deviceId)).collect(Collectors.toList());
+    }
+
+    @Override
     public Collection<Meter> getAllMeters() {
         return store.getAllMeters();
     }