-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
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;
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);
}
}
@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());
}
@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();
}
}