Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / MeterFeaturesService.java
index c6593134b95b7f4e8d33307b7e28d24921f763ac..0818e94303459e4e6a3c7c460ed971664460c2cc 100644 (file)
@@ -9,8 +9,9 @@ package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import java.util.ArrayList;
+import com.google.common.collect.ImmutableSet;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -48,9 +49,9 @@ final class MeterFeaturesService
     private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE =
             new MultipartRequestMeterFeaturesCaseBuilder().build();
 
-    MeterFeaturesService(RequestContextStack requestContextStack,
-                                DeviceContext deviceContext,
-                                AtomicLong compatibilityXidSeed) {
+    MeterFeaturesService(final RequestContextStack requestContextStack,
+                                final DeviceContext deviceContext,
+                                final AtomicLong compatibilityXidSeed) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
@@ -63,14 +64,15 @@ final class MeterFeaturesService
     }
 
     @Override
-    public GetMeterFeaturesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+    public GetMeterFeaturesOutput buildTxCapableResult(final TransactionId emulatedTxId) {
         return new GetMeterFeaturesOutputBuilder().setTransactionId(emulatedTxId).build();
     }
 
     @Override
-    public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+    public MeterFeaturesUpdated transformToNotification(final List<MultipartReply> result,
+            final TransactionId emulatedTxId) {
         final int mpSize = result.size();
-        Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+        Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: %s", mpSize);
 
         MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
         notification.setId(getDeviceInfo().getNodeId());
@@ -90,34 +92,33 @@ final class MeterFeaturesService
     }
 
     @VisibleForTesting
-    protected static List<Class<? extends MeterBand>> extractSupportedMeterBand(MultipartReplyMeterFeatures replyBody,
-                                                                         MeterBandTypeBitmap bandTypes) {
-        List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
-        if (bandTypes.isOFPMBTDROP()) {
-            supportedMeterBand.add(MeterBandDrop.class);
+    protected static Set<MeterBand> extractSupportedMeterBand(
+            final MultipartReplyMeterFeatures replyBody, final MeterBandTypeBitmap bandTypes) {
+        final var supportedMeterBand = ImmutableSet.<MeterBand>builder();
+        if (bandTypes.getOFPMBTDROP()) {
+            supportedMeterBand.add(MeterBandDrop.VALUE);
         }
-        if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
-            supportedMeterBand.add(MeterBandDscpRemark.class);
+        if (replyBody.getBandTypes().getOFPMBTDSCPREMARK()) {
+            supportedMeterBand.add(MeterBandDscpRemark.VALUE);
         }
-        return supportedMeterBand;
+        return supportedMeterBand.build();
     }
 
     @VisibleForTesting
-    protected static List<Class<? extends MeterCapability>> extractMeterCapabilities(MeterFlags capabilities) {
-        List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
-
-        if (capabilities.isOFPMFBURST()) {
-            supportedCapabilities.add(MeterBurst.class);
+    protected static Set<MeterCapability> extractMeterCapabilities(final MeterFlags capabilities) {
+        final var supportedCapabilities = ImmutableSet.<MeterCapability>builder();
+        if (capabilities.getOFPMFBURST()) {
+            supportedCapabilities.add(MeterBurst.VALUE);
         }
-        if (capabilities.isOFPMFKBPS()) {
-            supportedCapabilities.add(MeterKbps.class);
+        if (capabilities.getOFPMFKBPS()) {
+            supportedCapabilities.add(MeterKbps.VALUE);
         }
-        if (capabilities.isOFPMFPKTPS()) {
-            supportedCapabilities.add(MeterPktps.class);
+        if (capabilities.getOFPMFPKTPS()) {
+            supportedCapabilities.add(MeterPktps.VALUE);
         }
-        if (capabilities.isOFPMFSTATS()) {
-            supportedCapabilities.add(MeterStats.class);
+        if (capabilities.getOFPMFSTATS()) {
+            supportedCapabilities.add(MeterStats.VALUE);
         }
-        return supportedCapabilities;
+        return supportedCapabilities.build();
     }
 }