Bump MRI upstreams
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / MeterFeaturesService.java
index 142b3c0c85f6859c05b256e202a285966c3bc8bb..fb01bda3d4e1b24eb6edebf2d6b718b10bcbfca7 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -9,15 +9,16 @@ 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;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.services.util.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
@@ -45,9 +46,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 
 final class MeterFeaturesService
         extends AbstractCompatibleStatService<GetMeterFeaturesInput, GetMeterFeaturesOutput, MeterFeaturesUpdated> {
-    private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE = new MultipartRequestMeterFeaturesCaseBuilder().build();
+    private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE =
+            new MultipartRequestMeterFeaturesCaseBuilder().build();
 
-    public MeterFeaturesService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    MeterFeaturesService(final RequestContextStack requestContextStack,
+                                final DeviceContext deviceContext,
+                                final AtomicLong compatibilityXidSeed) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
@@ -60,21 +64,23 @@ 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(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
-        MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
+        MultipartReplyMeterFeaturesCase caseBody =
+                (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
         MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
         notification.setMaxBands(replyBody.getMaxBands());
         notification.setMaxColor(replyBody.getMaxColor());
@@ -86,33 +92,33 @@ final class MeterFeaturesService
     }
 
     @VisibleForTesting
-    protected List<Class<? extends MeterBand>> extractSupportedMeterBand(MultipartReplyMeterFeatures replyBody, MeterBandTypeBitmap bandTypes) {
-        List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
-        if (bandTypes.isOFPMBTDROP()) {
+    protected static Set<Class<? extends MeterBand>> extractSupportedMeterBand(
+            final MultipartReplyMeterFeatures replyBody, final MeterBandTypeBitmap bandTypes) {
+        final var supportedMeterBand = ImmutableSet.<Class<? extends MeterBand>>builder();
+        if (bandTypes.getOFPMBTDROP()) {
             supportedMeterBand.add(MeterBandDrop.class);
         }
-        if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
+        if (replyBody.getBandTypes().getOFPMBTDSCPREMARK()) {
             supportedMeterBand.add(MeterBandDscpRemark.class);
         }
-        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()) {
+    protected static Set<Class<? extends MeterCapability>> extractMeterCapabilities(final MeterFlags capabilities) {
+        final var supportedCapabilities = ImmutableSet.<Class<? extends MeterCapability>>builder();
+        if (capabilities.getOFPMFBURST()) {
             supportedCapabilities.add(MeterBurst.class);
         }
-        if (capabilities.isOFPMFKBPS()) {
+        if (capabilities.getOFPMFKBPS()) {
             supportedCapabilities.add(MeterKbps.class);
         }
-        if (capabilities.isOFPMFPKTPS()) {
+        if (capabilities.getOFPMFPKTPS()) {
             supportedCapabilities.add(MeterPktps.class);
         }
-        if (capabilities.isOFPMFSTATS()) {
+        if (capabilities.getOFPMFSTATS()) {
             supportedCapabilities.add(MeterStats.class);
         }
-        return supportedCapabilities;
+        return supportedCapabilities.build();
     }
 }