Fix findbugs violations in openflowplugin-impl 83/68983/5
authorTom Pantelis <tompantelis@gmail.com>
Fri, 2 Mar 2018 03:12:28 +0000 (22:12 -0500)
committerAnil Vishnoi <vishnoianil@gmail.com>
Fri, 2 Mar 2018 21:03:38 +0000 (21:03 +0000)
- Method ignores exceptional return value
- Check for sign of bitwise operation
- Consider using Locale parameterized version of invoked method
- Reliance on default encoding
- Synchronization performed on util.concurrent instance
- Unchecked/unconfirmed cast
- Unchecked/unconfirmed cast of return value from method
- Return value of method without side effect is ignored
- Dead store to local variable
- Method uses the same code for two branches
- Load of known null value
- Parameter must be non-null but is marked as nullable
- Field not initialized in constructor but dereferenced without null check

Change-Id: I92e00a5772038111d1ab8d9f53d52c43e3f4909d
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
86 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SimpleRatelimiter.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/mastership/MastershipChangeServiceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MatchDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/PacketInMessageDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyDescDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMessageDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartSerializerInjector.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/AbstractActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/AbstractSetFieldActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DropActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetFieldActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/AbstractActionInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/AbstractInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/ApplyActionsInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/ClearActionsInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/MeterInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteActionsInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestExperimenterSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/ActionUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerExperimenterMultipartService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerFlowService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalEchoServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerExperimenterMultipartService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsPollingService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/AddressNormalizationUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/GroupUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MeterUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java

index b4a9cc3fdf1608a01a3d94183116f8860e0b8a40..f1dd7155e367be2e8a034209948cd9a1634db8e0 100644 (file)
@@ -116,7 +116,7 @@ public class OpenFlowPluginProviderImpl implements
     private ConnectionManager connectionManager;
     private ListeningExecutorService executorService;
     private ContextChainHolderImpl contextChainHolder;
-    private OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor;
+    private final OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor;
 
     public static MessageIntelligenceAgency getMessageIntelligenceAgency() {
         return MESSAGE_INTELLIGENCE_AGENCY;
@@ -170,7 +170,7 @@ public class OpenFlowPluginProviderImpl implements
             return switchConnectionProvider.startup();
         }).collect(Collectors.toSet())), new FutureCallback<List<Boolean>>() {
             @Override
-            public void onSuccess(final List<Boolean> result) {
+            public void onSuccess(@Nonnull final List<Boolean> result) {
                 LOG.info("All switchConnectionProviders are up and running ({}).", result.size());
                 openflowPluginStatusMonitor.reportStatus(ServiceState.OPERATIONAL, "switch connections started");
             }
@@ -197,7 +197,7 @@ public class OpenFlowPluginProviderImpl implements
 
         Futures.addCallback(listListenableFuture, new FutureCallback<List<Boolean>>() {
             @Override
-            public void onSuccess(final List<Boolean> result) {
+            public void onSuccess(@Nonnull final List<Boolean> result) {
                 LOG.info("All switchConnectionProviders were successfully shut down ({}).", result.size());
             }
 
index 4c553f5cfe092b2d87bef093322e7e9dfb1ac77e..5d32cf64670a024ad3388e79ed7d13408bae1876 100644 (file)
@@ -18,6 +18,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler;
@@ -328,7 +329,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
         ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
         Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {
             @Override
-            public void onSuccess(RpcResult<Void> result) {
+            public void onSuccess(@Nonnull RpcResult<Void> result) {
                 if (result.isSuccessful()) {
                     LOG.debug("hello successfully sent, xid={}, addr={}", helloXid,
                               connectionAdapter.getRemoteAddress());
@@ -380,7 +381,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
         Futures.addCallback(JdkFutureAdapters.listenInPoolThread(featuresFuture),
                 new FutureCallback<RpcResult<GetFeaturesOutput>>() {
                     @Override
-                    public void onSuccess(RpcResult<GetFeaturesOutput> rpcFeatures) {
+                    public void onSuccess(@Nonnull RpcResult<GetFeaturesOutput> rpcFeatures) {
                         LOG.trace("features are back");
                         if (rpcFeatures.isSuccessful()) {
                             GetFeaturesOutput featureOutput = rpcFeatures.getResult();
index 42cec882840e9ffb6f15feff546cacc1bc0966d4..7c942f7afc8091ca8c56ea88ee1f5cd835b8c4e8 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.netty.util.HashedWheelTimer;
 import java.util.Collection;
 import java.util.Collections;
@@ -456,6 +457,9 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     @Override
+    // The cast to PacketInMessage is safe as the implemented interface is verified before the cas tbut FB doesn't
+    // recognize it.
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
     public boolean processAlienMessage(final OfHeader message) {
         final Class<? extends DataContainer> implementedInterface = message.getImplementedInterface();
 
index 365674f2ab547fd45664ae4a794b0124980ae262..d5d9c78469ff4b7558a286279ddb36d86456c84c 100644 (file)
@@ -62,6 +62,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private final NotificationPublishService notificationPublishService;
     private final MessageSpy messageSpy;
     private final HashedWheelTimer hashedWheelTimer;
+    private final Object updatePacketInRateLimitersLock = new Object();
     private TranslatorLibrary translatorLibrary;
     private ExtensionConverterProvider extensionConverterProvider;
     private ScheduledThreadPoolExecutor spyPool;
@@ -128,6 +129,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
     }
 
+    @Override
     public DeviceContext createContext(@Nonnull final ConnectionContext connectionContext) {
 
         LOG.info("ConnectionEvent: Device connected to controller, Device:{}, NodeId:{}",
@@ -177,7 +179,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     private void updatePacketInRateLimiters() {
-        synchronized (deviceContexts) {
+        synchronized (updatePacketInRateLimitersLock) {
             final int deviceContextsSize = deviceContexts.size();
             if (deviceContextsSize > 0) {
                 long freshNotificationLimit = config.getGlobalNotificationQuota() / deviceContextsSize;
@@ -200,9 +202,8 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         if (LOG.isDebugEnabled()) {
             LOG.debug("Device context removed for node {}", deviceInfo);
         }
-        if (deviceContexts.size() > 0) {
-            this.updatePacketInRateLimiters();
-        }
+
+        this.updatePacketInRateLimiters();
     }
 
     @Override
index 0c2578303a34892988add02ea36897a8abac3931..4baf160ae164db6e0d8506775d5a94a1c835086e 100644 (file)
@@ -13,10 +13,12 @@ import javax.annotation.concurrent.GuardedBy;
 
 abstract class SimpleRatelimiter {
     private final AtomicInteger counter = new AtomicInteger();
+    private final Object counterLock = new Object();
+    @GuardedBy("counterLock")
     private int lowWatermark;
-    private int lowWatermarkEffective;
-    private int highWatermark;
-    @GuardedBy("counter")
+    private volatile int lowWatermarkEffective;
+    private volatile int highWatermark;
+    @GuardedBy("counterLock")
     private volatile boolean limited;
 
     SimpleRatelimiter(final int lowWatermark, final int highWatermark) {
@@ -40,7 +42,7 @@ abstract class SimpleRatelimiter {
     boolean acquirePermit() {
         final int cnt = counter.incrementAndGet();
         if (cnt > highWatermark) {
-            synchronized (counter) {
+            synchronized (counterLock) {
                 final int recheck = counter.decrementAndGet();
                 if (recheck >= highWatermark && !limited) {
                     disableFlow();
@@ -56,7 +58,7 @@ abstract class SimpleRatelimiter {
     void releasePermit() {
         final int cnt = counter.decrementAndGet();
         if (cnt <= lowWatermarkEffective) {
-            synchronized (counter) {
+            synchronized (counterLock) {
                 final int recheck = counter.get();
                 if (recheck <= lowWatermarkEffective && limited) {
                     enableFlow();
@@ -67,15 +69,14 @@ abstract class SimpleRatelimiter {
         }
     }
 
-    void resetLowWaterMark() {
-        synchronized (counter) {
-            lowWatermarkEffective = lowWatermark;
-        }
+    @GuardedBy("counterLock")
+    private void resetLowWaterMark() {
+        lowWatermarkEffective = lowWatermark;
     }
 
     void adaptLowWaterMarkAndDisableFlow(int temporaryLowWaterMark) {
         if (temporaryLowWaterMark < highWatermark) {
-            synchronized (counter) {
+            synchronized (counterLock) {
                 lowWatermarkEffective = temporaryLowWaterMark;
                 if (!limited) {
                     disableFlow();
@@ -90,7 +91,7 @@ abstract class SimpleRatelimiter {
     }
 
     void changeWaterMarks(final int newLowWatermark, final int newHighWatermark) {
-        synchronized (counter) {
+        synchronized (counterLock) {
             lowWatermark = newLowWatermark;
             highWatermark = newHighWatermark;
             resetLowWaterMark();
index e219f636068aa7b78a2b6272400daa3d39c4ecfe..26e4d38f1baf838d3cd05de37d28127e760d57da 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
-import java.util.List;
 import java.util.concurrent.Future;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -41,13 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeCon
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -159,29 +156,14 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
                     new SingleLayerMultipartCollectorService(deviceContext, deviceContext);
 
             return Futures.transform(service.handleServiceCall(multipartType),
-                    new Function<RpcResult<List<MultipartReply>>, Boolean>() {
-                        @Nonnull
-                        @Override
-                        public Boolean apply(final RpcResult<List<MultipartReply>> input) {
-                            return input.isSuccessful();
-                        }
-                    }, MoreExecutors.directExecutor());
+                input -> input.isSuccessful(), MoreExecutors.directExecutor());
         }
 
         final MultiLayerMultipartCollectorService service =
                 new MultiLayerMultipartCollectorService(deviceContext, deviceContext);
 
         return Futures.transform(service.handleServiceCall(multipartType),
-                new Function<RpcResult<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol
-                        .rev130731.MultipartReply>>, Boolean>() {
-                    @Nonnull
-                    @Override
-                    public Boolean apply(final RpcResult<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
-                            .protocol
-                            .rev130731.MultipartReply>> input) {
-                        return input.isSuccessful();
-                    }
-                }, MoreExecutors.directExecutor());
+            input -> input.isSuccessful(), MoreExecutors.directExecutor());
     }
 
 }
index 93baca850b5d12226f8f506c9595a6ee5daaa07b..d3297904a00ca6f79599a353c080c61cacd3a775 100644 (file)
@@ -35,7 +35,6 @@ import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtil;
 import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -84,7 +83,7 @@ public class OF13DeviceInitializer extends AbstractDeviceInitializer {
                         multipartWriterProvider, convertorExecutor));
 
                 return Futures.transform(
-                    (switchFeaturesMandatory ? Futures.allAsList(futures) : Futures.successfulAsList(futures)),
+                    switchFeaturesMandatory ? Futures.allAsList(futures) : Futures.successfulAsList(futures),
                     new Function<List<RpcResult<List<OfHeader>>>, Void>() {
                         @Nullable
                         @Override
@@ -139,7 +138,7 @@ public class OF13DeviceInitializer extends AbstractDeviceInitializer {
                                        @Nullable final ConvertorExecutor convertorExecutor) {
         Futures.addCallback(future, new FutureCallback<RpcResult<List<OfHeader>>>() {
             @Override
-            public void onSuccess(final RpcResult<List<OfHeader>> result) {
+            public void onSuccess(@Nonnull final RpcResult<List<OfHeader>> result) {
                 if (Objects.nonNull(result.getResult())) {
                     LOG.info("Static node {} info: {} collected", deviceContext.getDeviceInfo(), type);
                     translateAndWriteResult(
@@ -241,55 +240,35 @@ public class OF13DeviceInitializer extends AbstractDeviceInitializer {
                     new SingleLayerMultipartCollectorService(deviceContext, deviceContext);
 
             return Futures.transform(service.handleServiceCall(multipartType),
-                    new Function<RpcResult<List<MultipartReply>>, RpcResult<List<OfHeader>>>() {
-                        @Nonnull
-                        @Override
-                        public RpcResult<List<OfHeader>> apply(final RpcResult<List<MultipartReply>> input) {
-                            if (Objects.isNull(input.getResult()) && input.isSuccessful()) {
-                                final List<OfHeader> temp = null;
-                                return RpcResultBuilder.success(temp).build();
-                            }
+                input -> {
+                    if (Objects.isNull(input.getResult()) && input.isSuccessful()) {
+                        return RpcResultBuilder.<List<OfHeader>>success(null).build();
+                    }
 
-                            return input.isSuccessful()
-                                    ? RpcResultBuilder.success(input
+                    return input.isSuccessful()
+                            ? RpcResultBuilder.success(input
                                     .getResult()
                                     .stream()
                                     .map(OfHeader.class::cast)
                                     .collect(Collectors.toList()))
                                     .build()
-                                    : RpcResultBuilder.<List<OfHeader>>failed()
+                            : RpcResultBuilder.<List<OfHeader>>failed()
                                     .withRpcErrors(input.getErrors())
                                     .build();
-                        }
-                    }, MoreExecutors.directExecutor());
+                }, MoreExecutors.directExecutor());
         }
 
         final MultiLayerMultipartCollectorService service =
             new MultiLayerMultipartCollectorService(deviceContext, deviceContext);
 
-        return Futures.transform(service.handleServiceCall(multipartType), new Function<RpcResult<List<org
-                .opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply>>,
-                RpcResult<List<OfHeader>>>() {
-            @Nonnull
-            @Override
-            public RpcResult<List<OfHeader>> apply(final RpcResult<List<org.opendaylight.yang.gen.v1.urn.opendaylight
-                    .openflow.protocol.rev130731.MultipartReply>> input) {
-                if (Objects.isNull(input.getResult()) && input.isSuccessful()) {
-                    final List<OfHeader> temp = null;
-                    return RpcResultBuilder.success(temp).build();
-                }
-
-                return input.isSuccessful()
-                        ? RpcResultBuilder.success(input
-                        .getResult()
-                        .stream()
-                        .map(OfHeader.class::cast)
-                        .collect(Collectors.toList()))
-                        .build()
-                        : RpcResultBuilder.<List<OfHeader>>failed()
-                        .withRpcErrors(input.getErrors())
-                        .build();
+        return Futures.transform(service.handleServiceCall(multipartType), input -> {
+            if (Objects.isNull(input.getResult()) && input.isSuccessful()) {
+                return RpcResultBuilder.<List<OfHeader>>success(null).build();
             }
+
+            return input.isSuccessful() ? RpcResultBuilder
+                    .success(input.getResult().stream().map(OfHeader.class::cast).collect(Collectors.toList())).build()
+                    : RpcResultBuilder.<List<OfHeader>>failed().withRpcErrors(input.getErrors()).build();
         }, MoreExecutors.directExecutor());
     }
 
index 6b8bf8b8733d23bf6e9d40c480c38eba0371be5f..387a7bdbe901a89ae566e4891933c4654c03c2c6 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -272,11 +273,15 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
     }
 
     @Override
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
     public void ownershipChanged(EntityOwnershipChange entityOwnershipChange) {
         if (entityOwnershipChange.getState().hasOwner()) {
             return;
         }
 
+        // Findbugs flags a false violation for "Unchecked/unconfirmed cast" from GenericEntity to Entity hence the
+        // suppression above. The suppression is temporary until EntityOwnershipChange is modified to eliminate the
+        // violation.
         final String entityName = entityOwnershipChange
                 .getEntity()
                 .getIdentifier()
index 3702c9e2a10f61c2638da7c2a287e7dc4796caf5..ff58ba0e7d2e61097151dacbd48fdaaa5f9364a1 100644 (file)
@@ -75,7 +75,7 @@ public class ContextChainImpl implements ContextChain {
             LOG.info("Started clustering services for node {}", deviceInfo);
         } catch (final Exception ex) {
             LOG.warn("Not able to start clustering services for node {}", deviceInfo);
-            executorService.submit(() -> contextChainMastershipWatcher
+            executorService.execute(() -> contextChainMastershipWatcher
                     .onNotAbleToStartMastershipMandatory(deviceInfo, ex.toString()));
         }
     }
@@ -217,8 +217,8 @@ public class ContextChainImpl implements ContextChain {
 
     @Override
     public boolean addAuxiliaryConnection(@Nonnull ConnectionContext connectionContext) {
-        return (connectionContext.getFeatures().getAuxiliaryId() != 0)
-                && (!ConnectionContext.CONNECTION_STATE.RIP.equals(primaryConnection.getConnectionState()))
+        return connectionContext.getFeatures().getAuxiliaryId() != 0
+                && !ConnectionContext.CONNECTION_STATE.RIP.equals(primaryConnection.getConnectionState())
                 && auxiliaryConnections.add(connectionContext);
     }
 
@@ -256,4 +256,4 @@ public class ContextChainImpl implements ContextChain {
         masterStateOnDevice.set(false);
         rpcRegistration.set(false);
     }
-}
\ No newline at end of file
+}
index d7174e5fa87e0d70353a195aa2d11ba549ab4145..240c2411aaad734fbda52b8c8a77f62ba62a3d35 100644 (file)
@@ -9,8 +9,9 @@ package org.opendaylight.openflowplugin.impl.mastership;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.ArrayList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.MasterChecker;
@@ -24,7 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 
 public final class MastershipChangeServiceManagerImpl implements MastershipChangeServiceManager {
 
-    private final List<MastershipChangeService> serviceGroup = new ArrayList<>();
+    private final List<MastershipChangeService> serviceGroup = new CopyOnWriteArrayList<>();
     private ReconciliationFrameworkEvent rfService = null;
     private MasterChecker masterChecker;
 
@@ -35,7 +36,7 @@ public final class MastershipChangeServiceManagerImpl implements MastershipChang
                 new MastershipServiceDelegate(service, () -> serviceGroup.remove(service));
         serviceGroup.add(service);
         if (masterChecker != null && masterChecker.isAnyDeviceMastered()) {
-            fireBecomeOwnerAfterRegistration(service);
+            masterChecker.listOfMasteredDevices().forEach(service::onBecomeOwner);
         }
         return registration;
     }
@@ -62,6 +63,8 @@ public final class MastershipChangeServiceManagerImpl implements MastershipChang
     }
 
     @Override
+    // FB flags this for onDeviceDisconnected but unclear why - seems a false positive.
+    @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
     public void becomeSlaveOrDisconnect(@Nonnull final DeviceInfo deviceInfo) {
         if (rfService != null) {
             rfService.onDeviceDisconnected(deviceInfo);
@@ -81,15 +84,11 @@ public final class MastershipChangeServiceManagerImpl implements MastershipChang
 
     @Override
     public boolean isReconciliationFrameworkRegistered() {
-        return (rfService != null);
+        return rfService != null;
     }
 
     @VisibleForTesting
     int serviceGroupListSize() {
         return serviceGroup.size();
     }
-
-    private void fireBecomeOwnerAfterRegistration(@Nonnull final MastershipChangeService service) {
-        masterChecker.listOfMasteredDevices().forEach(service::onBecomeOwner);
-    }
 }
index dc3bd432b54e92cb592e7dc6c37c43532a4b49b4..884ceb2ffdfa85566ede95fc2ae1c29a9f4c763f 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
@@ -35,7 +36,7 @@ public class SetFieldActionDeserializer extends AbstractActionDeserializer
 
     @Override
     public Action deserialize(ByteBuf message) {
-        final MatchEntryDeserializer deserializer = registry.getDeserializer(MATCH_KEY);
+        final MatchEntryDeserializer deserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
         final MatchBuilder builder = new MatchBuilder();
 
         final int startIndex = message.readerIndex();
index 76423e6acc8a8a9ad224ca1dfba19c7705fb7a36..7e96fdb4c3e59c40aa6be812dd3a09b31877e55f 100644 (file)
@@ -9,11 +9,9 @@
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 
 import io.netty.buffer.ByteBuf;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
-
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
@@ -51,13 +49,13 @@ public class MatchDeserializer implements OFDeserializer<Match>, HeaderDeseriali
         final MatchBuilder builder = new MatchBuilder();
 
         // OFP do not have any method to differentiate between OXM and standard match, so we do not care about type
-        final int type = inBuffer.readUnsignedShort();
+        inBuffer.readUnsignedShort();
         final int length = inBuffer.readUnsignedShort();
 
         final int startIndex = inBuffer.readerIndex();
         final int entriesLength = length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
 
-        while ((inBuffer.readerIndex() - startIndex) < entriesLength) {
+        while (inBuffer.readerIndex() - startIndex < entriesLength) {
             deserializeEntry(inBuffer, builder);
         }
 
index 5382da8896d30a829d73ffa50543786fa8849f8f..15e45231d18df063a5f50b30efb42f60edab22c3 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.messages;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -65,7 +66,7 @@ public class FlowMessageDeserializer implements OFDeserializer<FlowMessage>, Des
 
         message.skipBytes(PADDING);
 
-        final OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY);
+        final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
         builder.setMatch(new MatchBuilder(matchDeserializer.deserialize(message)).build());
 
         final int length = message.readableBytes();
@@ -81,13 +82,13 @@ public class FlowMessageDeserializer implements OFDeserializer<FlowMessage>, Des
                 OFDeserializer<Instruction> deserializer = null;
 
                 if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
-                    deserializer = registry.getDeserializer(
+                    deserializer = Preconditions.checkNotNull(registry).getDeserializer(
                             new MessageCodeActionExperimenterKey(
                                 EncodeConstants.OF13_VERSION_ID, type, Instruction.class,
                                 ActionPath.INVENTORY_FLOWNODE_TABLE_APPLY_ACTIONS,
                                 null));
                 } else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
-                    deserializer = registry.getDeserializer(
+                    deserializer = Preconditions.checkNotNull(registry).getDeserializer(
                             new MessageCodeActionExperimenterKey(
                                 EncodeConstants.OF13_VERSION_ID, type, Instruction.class,
                                 ActionPath.INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS,
@@ -100,7 +101,7 @@ public class FlowMessageDeserializer implements OFDeserializer<FlowMessage>, Des
                                 + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
                     }
 
-                    deserializer = registry.getDeserializer(
+                    deserializer = Preconditions.checkNotNull(registry).getDeserializer(
                             new MessageCodeExperimenterKey(
                                 EncodeConstants.OF13_VERSION_ID, type, Instruction.class, expId));
                 }
@@ -123,11 +124,11 @@ public class FlowMessageDeserializer implements OFDeserializer<FlowMessage>, Des
     }
 
     private static FlowModFlags createFlowModFlagsFromBitmap(int input) {
-        final Boolean ofp_FF_SendFlowRem = (input & 1 << 0) > 0;
-        final Boolean ofp_FF_CheckOverlap = (input & 1 << 1) > 0;
-        final Boolean ofp_FF_ResetCounts = (input & 1 << 2) > 0;
-        final Boolean ofp_FF_NoPktCounts = (input & 1 << 3) > 0;
-        final Boolean ofp_FF_NoBytCounts = (input & 1 << 4) > 0;
+        final Boolean ofp_FF_SendFlowRem = (input & 1 << 0) != 0;
+        final Boolean ofp_FF_CheckOverlap = (input & 1 << 1) != 0;
+        final Boolean ofp_FF_ResetCounts = (input & 1 << 2) != 0;
+        final Boolean ofp_FF_NoPktCounts = (input & 1 << 3) != 0;
+        final Boolean ofp_FF_NoBytCounts = (input & 1 << 4) != 0;
         return new FlowModFlags(ofp_FF_CheckOverlap, ofp_FF_NoBytCounts, ofp_FF_NoPktCounts, ofp_FF_ResetCounts,
                 ofp_FF_SendFlowRem);
     }
index d1f423bfcdb53ec674db558ac2f4100392a10c32..c4f6f09044dcd91a05ec807a6d2930eae0fc35ee 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.messages;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
@@ -46,8 +47,8 @@ public class PacketInMessageDeserializer implements OFDeserializer<PacketInMessa
                 .setXid(message.readUnsignedInt());
 
         // We are ignoring buffer id and total len as it is not specified in OpenFlowPlugin models
-        final long bufferId = message.readUnsignedInt();
-        final int totalLen = message.readUnsignedShort();
+        message.readUnsignedInt();
+        message.readUnsignedShort();
 
         packetInMessageBuilder
                 .setPacketInReason(PacketInUtil
@@ -61,7 +62,7 @@ public class PacketInMessageDeserializer implements OFDeserializer<PacketInMessa
         packetInMessageBuilder
                 .setFlowCookie(new FlowCookie(new BigInteger(1, cookie)));
 
-        final OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY);
+        final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
 
         packetInMessageBuilder.setMatch(MatchUtil.transformMatch(matchDeserializer.deserialize(message),
                 org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.in.message
index 97caa46e85f528061cd23f26405207a1e9100a53..d06886d84fafd91e2b588ededdd1e4eb6dce0c81 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
 
 import io.netty.buffer.ByteBuf;
+import java.nio.charset.StandardCharsets;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
@@ -35,11 +36,11 @@ public class MultipartReplyDescDeserializer implements OFDeserializer<MultipartR
         message.readBytes(dpDescBytes);
 
         return new MultipartReplyDescBuilder()
-                .setManufacturer(new String(mfrDescBytes).trim())
-                .setHardware(new String(hwDescBytes).trim())
-                .setSoftware(new String(swDescBytes).trim())
-                .setSerialNumber(new String(serialNumBytes).trim())
-                .setDescription(new String(dpDescBytes).trim())
+                .setManufacturer(new String(mfrDescBytes, StandardCharsets.UTF_8).trim())
+                .setHardware(new String(hwDescBytes, StandardCharsets.UTF_8).trim())
+                .setSoftware(new String(swDescBytes, StandardCharsets.UTF_8).trim())
+                .setSerialNumber(new String(serialNumBytes, StandardCharsets.UTF_8).trim())
+                .setDescription(new String(dpDescBytes, StandardCharsets.UTF_8).trim())
                 .build();
     }
 
index 24aa58677cafb7d34a2cafc5c3cf4ddd328d437f..adfec1d1e8eee33439b5bc2ca7b2b176f3cce9de 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -85,7 +86,8 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer<Multi
                     .setPacketCount(new Counter64(new BigInteger(1, packetCount)))
                     .setByteCount(new Counter64(new BigInteger(1, byteCount)));
 
-            final OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY);
+            final OFDeserializer<Match> matchDeserializer =
+                    Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
             itemBuilder.setMatch(MatchUtil.transformMatch(matchDeserializer.deserialize(itemMessage),
                     org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match.class));
 
@@ -122,11 +124,11 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer<Multi
     }
 
     private static FlowModFlags createFlowModFlagsFromBitmap(int input) {
-        final Boolean ofp_FF_SendFlowRem = (input & 1) > 0;
-        final Boolean ofp_FF_CheckOverlap = (input & 1 << 1) > 0;
-        final Boolean ofp_FF_ResetCounts = (input & 1 << 2) > 0;
-        final Boolean ofp_FF_NoPktCounts = (input & 1 << 3) > 0;
-        final Boolean ofp_FF_NoBytCounts = (input & 1 << 4) > 0;
+        final Boolean ofp_FF_SendFlowRem = (input & 1) != 0;
+        final Boolean ofp_FF_CheckOverlap = (input & 1 << 1) != 0;
+        final Boolean ofp_FF_ResetCounts = (input & 1 << 2) != 0;
+        final Boolean ofp_FF_NoPktCounts = (input & 1 << 3) != 0;
+        final Boolean ofp_FF_NoBytCounts = (input & 1 << 4) != 0;
         return new FlowModFlags(ofp_FF_CheckOverlap, ofp_FF_NoBytCounts, ofp_FF_NoPktCounts, ofp_FF_ResetCounts,
                 ofp_FF_SendFlowRem);
     }
index 82a80092c2756d96f1d7251766eb34a3de71d055..945046df7c5fff6eeb449ae9be3d671d6d3b8bde 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
@@ -32,7 +33,7 @@ public class MultipartReplyMessageDeserializer implements OFDeserializer<Multipa
         final boolean reqMore = (message.readUnsignedShort() & 0x01) != 0;
         message.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
 
-        final OFDeserializer<MultipartReplyBody> deserializer = registry
+        final OFDeserializer<MultipartReplyBody> deserializer = Preconditions.checkNotNull(registry)
             .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
                         type, MultipartReplyBody.class));
 
index da138d0b7c7cd8841f73407af7b9a702a52fe57d..5482c81284993a3bc77f658b8535954d8fd454c3 100644 (file)
@@ -63,7 +63,8 @@ final class MultipartSerializerInjector {
      */
     static void injectSerializers(final SerializerExtensionProvider provider) {
         // Inject new message serializers here using injector created by createInjector method
-        final Function<Class<? extends MultipartRequestBody>, Consumer<OFSerializer<MultipartRequestBody>>> injector =
+        final Function<Class<? extends MultipartRequestBody>,
+            Consumer<OFSerializer<? extends MultipartRequestBody>>> injector =
                 createInjector(provider, EncodeConstants.OF13_VERSION_ID);
 
         MultipartMatchFieldSerializerInjector.injectSerializers(provider);
@@ -96,9 +97,9 @@ final class MultipartSerializerInjector {
      * @return injector
      */
     @VisibleForTesting
-    static Function<Class<? extends MultipartRequestBody>, Consumer<OFSerializer<MultipartRequestBody>>> createInjector(
-            final SerializerExtensionProvider provider,
-            final byte version) {
+    static Function<Class<? extends MultipartRequestBody>,
+            Consumer<OFSerializer<? extends MultipartRequestBody>>> createInjector(
+                    final SerializerExtensionProvider provider, final byte version) {
         return type -> serializer ->
                 provider.registerSerializer(
                         new MessageTypeKey<>(version, type),
index 23bedd401fe8cdfb6f5f1149254df2c38def4b30..839e5775120d37c3e4ded9500431a2215bccf4e2 100644 (file)
@@ -14,15 +14,15 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public abstract class AbstractActionSerializer implements OFSerializer<Action>, HeaderSerializer<Action> {
+public abstract class AbstractActionSerializer<T extends Action> implements OFSerializer<T>, HeaderSerializer<T> {
     @Override
-    public void serialize(Action input, ByteBuf outBuffer) {
+    public void serialize(T input, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
         outBuffer.writeShort(getLength());
     }
 
     @Override
-    public void serializeHeader(Action input, ByteBuf outBuffer) {
+    public void serializeHeader(T input, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
         outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH);
     }
index 0b58b262f95d72f57b25afdeab6dc78e1525d4f7..b5b2a6a843992dec4409a21b5820df0b20cf8007 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -18,14 +19,14 @@ import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
 
-public abstract class AbstractSetFieldActionSerializer extends AbstractActionSerializer implements
+public abstract class AbstractSetFieldActionSerializer extends AbstractActionSerializer<Action> implements
         SerializerRegistryInjector {
 
     private SerializerRegistry registry;
 
     @Override
     public void serialize(Action input, ByteBuf outBuffer) {
-        final OFSerializer<Action> serializer = registry
+        final OFSerializer<Action> serializer = Preconditions.checkNotNull(registry)
                 .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, SetFieldCase.class));
 
         serializer.serialize(buildAction(input), outBuffer);
index 9ea760c5385fe0ca6d4a58d1381ff2542b06e162..2988815d490b4e49314929a42ee11f5ea1ca2917 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class CopyTtlInActionSerializer extends AbstractActionSerializer {
+public class CopyTtlInActionSerializer extends AbstractActionSerializer<Action> {
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
index c9114d2015c7f69f11f71701fcdf1dcc3b39721b..cdd42a1b3e9523f1769e9f3002a40d779502132d 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class CopyTtlOutActionSerializer extends AbstractActionSerializer {
+public class CopyTtlOutActionSerializer extends AbstractActionSerializer<Action> {
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
index fb624215b07384459bd1a56d18498706eae616f6..dedb47f388a5bf67360efb8cacd01f43b0a5cb27 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class DecMplsTtlActionSerializer extends AbstractActionSerializer {
+public class DecMplsTtlActionSerializer extends AbstractActionSerializer<Action> {
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
index e758ab18f0eeda0b9b8171e0cf225800ebe116c3..16726716611e01eae9abb480039cf6c24694b96e 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class DecNwTtlActionSerializer extends AbstractActionSerializer {
+public class DecNwTtlActionSerializer extends AbstractActionSerializer<Action> {
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
index 22d3e717e4a50ecdb0074c7320e6a483029488f8..b6c5316e9b8149b8e0edff03098d326f80a6eab4 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class DropActionSerializer extends AbstractActionSerializer {
+public class DropActionSerializer extends AbstractActionSerializer<Action> {
 
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
index e52f2afffe61adf0abb25dbc16ba90e37b6462ea..93462a44a05535eb846906bcc992f60e1a60d95b 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
 
-public class GroupActionSerializer extends AbstractActionSerializer {
+public class GroupActionSerializer extends AbstractActionSerializer<GroupActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(GroupActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final GroupAction groupAction = GroupActionCase.class.cast(action).getGroupAction();
+        final GroupAction groupAction = action.getGroupAction();
         outBuffer.writeInt(groupAction.getGroupId().intValue());
     }
 
index 176e991e31cec76f34f1a4dc9fc50aa7a823bdc6..0b2b35be122ba25ded3699ef13ab31785504b7f0 100644 (file)
@@ -13,16 +13,15 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
 
-public class OutputActionSerializer extends AbstractActionSerializer {
+public class OutputActionSerializer extends AbstractActionSerializer<OutputActionCase> {
 
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(OutputActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final OutputAction outputAction = OutputActionCase.class.cast(action).getOutputAction();
+        final OutputAction outputAction = action.getOutputAction();
         Long value = InventoryDataServiceUtil.portNumberfromNodeConnectorId(
                 OpenflowVersion.OF13,
                 outputAction.getOutputNodeConnector().getValue());
index 952e077c742fd6c27c3c4180a1beb8a7a9a5592b..d5391091a9a30525a76117982f4e997e639536c9 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsAction;
 
-public class PopMplsActionSerializer extends AbstractActionSerializer {
+public class PopMplsActionSerializer extends AbstractActionSerializer<PopMplsActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(PopMplsActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final PopMplsAction popMplsAction = PopMplsActionCase.class.cast(action).getPopMplsAction();
+        final PopMplsAction popMplsAction = action.getPopMplsAction();
         outBuffer.writeShort(popMplsAction.getEthernetType());
         outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
     }
index 5142dc6737c810f6bc98e55bbaf0e1a35df73e60..f890ad768eaa49e46a19a02b4fc285c479b77f53 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class PopPbbActionSerializer extends AbstractActionSerializer {
+public class PopPbbActionSerializer extends AbstractActionSerializer<Action> {
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
index 87f5a56605b2ad58e3c7021d8000f4e99311bd3b..391ddd5e03ee5cb895565ac5804b9dc3eb686506 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
-public class PopVlanActionSerializer extends AbstractActionSerializer {
+public class PopVlanActionSerializer extends AbstractActionSerializer<Action> {
     @Override
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
index 84baee876aeca6ddeab3cff8b0f8cfbb48339dfd..4ab4cab24afd1ae7b07d744908a9f5236d5342a0 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsAction;
 
-public class PushMplsActionSerializer extends AbstractActionSerializer {
+public class PushMplsActionSerializer extends AbstractActionSerializer<PushMplsActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(PushMplsActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final PushMplsAction pushMplsAction = PushMplsActionCase.class.cast(action).getPushMplsAction();
+        final PushMplsAction pushMplsAction = action.getPushMplsAction();
         outBuffer.writeShort(pushMplsAction.getEthernetType());
         outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
     }
index 9c04c9b2ea81db7acff6c1f5e2258a18199eaa36..9432a8d5c4ac51274ce44cf9ac7a52b51f788c82 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbAction;
 
-public class PushPbbActionSerializer extends AbstractActionSerializer {
+public class PushPbbActionSerializer extends AbstractActionSerializer<PushPbbActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(PushPbbActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final PushPbbAction pushPbbAction = PushPbbActionCase.class.cast(action).getPushPbbAction();
+        final PushPbbAction pushPbbAction = action.getPushPbbAction();
         outBuffer.writeShort(pushPbbAction.getEthernetType());
         outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
     }
index 4318fcdbe15da40b0f8619d77092f2eb3069b75a..22e95e729c2eaaf27a87f1d1f9ca19d75feb7620 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
 
-public class PushVlanActionSerializer extends AbstractActionSerializer {
+public class PushVlanActionSerializer extends AbstractActionSerializer<PushVlanActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(PushVlanActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final PushVlanAction pushVlanAction = PushVlanActionCase.class.cast(action).getPushVlanAction();
+        final PushVlanAction pushVlanAction = action.getPushVlanAction();
         outBuffer.writeShort(pushVlanAction.getEthernetType());
         outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
     }
index 4c009504495a0ec5ed053fe36b061d0337fb6e0c..cfe0ca4d44ea51cdaadac92c8580e4048a3af330 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -15,16 +16,16 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegist
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 
-public class SetFieldActionSerializer extends AbstractActionSerializer implements SerializerRegistryInjector {
+public class SetFieldActionSerializer extends AbstractActionSerializer<SetFieldCase>
+        implements SerializerRegistryInjector {
     private SerializerRegistry registry;
 
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(SetFieldCase action, ByteBuf outBuffer) {
         // Serialize field type and save position
         final int startIndex = outBuffer.writerIndex();
         outBuffer.writeShort(getType());
@@ -32,8 +33,8 @@ public class SetFieldActionSerializer extends AbstractActionSerializer implement
         outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
 
         // Serialize match (using small workaround with serializeHeader method to serialize only match entries)
-        final SetField setField = SetFieldCase.class.cast(action).getSetField();
-        final HeaderSerializer<Match> serializer = registry
+        final SetField setField = action.getSetField();
+        final HeaderSerializer<Match> serializer = Preconditions.checkNotNull(registry)
                 .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class));
         serializer.serializeHeader(setField, outBuffer);
 
index 17769d2dbb86a1c2c8cee4789eea02c09a839bc1..dff5193dce2c69c7d8823d9164bff35457cebabe 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
 
-public class SetMplsTtlActionSerializer extends AbstractActionSerializer {
+public class SetMplsTtlActionSerializer extends AbstractActionSerializer<SetMplsTtlActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(SetMplsTtlActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final SetMplsTtlAction setMplsTtlAction = SetMplsTtlActionCase.class.cast(action).getSetMplsTtlAction();
+        final SetMplsTtlAction setMplsTtlAction = action.getSetMplsTtlAction();
         outBuffer.writeByte(setMplsTtlAction.getMplsTtl());
         outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING);
     }
index db93e8ed54a5d33668a5df6b1b5e11a6fa751731..40a0c3661931e91988aa4f2f86d4d57d6d70998e 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlAction;
 
-public class SetNwTtlActionSerializer extends AbstractActionSerializer {
+public class SetNwTtlActionSerializer extends AbstractActionSerializer<SetNwTtlActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(SetNwTtlActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final SetNwTtlAction setNwTtlAction = SetNwTtlActionCase.class.cast(action).getSetNwTtlAction();
+        final SetNwTtlAction setNwTtlAction = action.getSetNwTtlAction();
         outBuffer.writeByte(setNwTtlAction.getNwTtl());
         outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING);
     }
index 603f59bf102bba9074e47393921980f391835b9b..32c526e5f6be4525b029f6a784dc985b1c8566d6 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
 
-public class SetQueueActionSerializer extends AbstractActionSerializer {
+public class SetQueueActionSerializer extends AbstractActionSerializer<SetQueueActionCase> {
     @Override
-    public void serialize(Action action, ByteBuf outBuffer) {
+    public void serialize(SetQueueActionCase action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        final SetQueueAction setQueueAction = SetQueueActionCase.class.cast(action).getSetQueueAction();
+        final SetQueueAction setQueueAction = action.getSetQueueAction();
         outBuffer.writeInt(setQueueAction.getQueueId().intValue());
     }
 
index 393f6bfc90b15a152f085479c21cb67ef8ef2744..49b5e7e9c77751f6c2b86c8161fe658ffcc7eeb6 100644 (file)
@@ -19,13 +19,13 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Ord
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.ActionList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 
-public abstract class AbstractActionInstructionSerializer extends AbstractInstructionSerializer implements
-        SerializerRegistryInjector {
+public abstract class AbstractActionInstructionSerializer<T extends Instruction>
+        extends AbstractInstructionSerializer<T> implements SerializerRegistryInjector {
 
     private SerializerRegistry registry;
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(T input, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
     }
 
index b747d89e36408f6f133b5319a70da4f07eacb3a0..ee76b05ebf999c06a3e5bdd390d5162e84145135 100644 (file)
@@ -14,17 +14,17 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 
-public abstract class AbstractInstructionSerializer implements OFSerializer<Instruction>,
-        HeaderSerializer<Instruction> {
+public abstract class AbstractInstructionSerializer<T extends Instruction> implements OFSerializer<T>,
+        HeaderSerializer<T> {
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(T input, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
         outBuffer.writeShort(getLength());
     }
 
     @Override
-    public void serializeHeader(Instruction input, ByteBuf outBuffer) {
+    public void serializeHeader(T input, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
         outBuffer.writeShort(InstructionConstants.INSTRUCTION_IDS_LENGTH);
     }
index 87235d5b19868e87a2d14208e189e41959be9add..02f7ac616376327ccbf897f8311c8179365e5a5e 100644 (file)
@@ -11,17 +11,15 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
 
-public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer {
+public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer<ApplyActionsCase> {
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(ApplyActionsCase input, ByteBuf outBuffer) {
         int index = outBuffer.writerIndex();
         super.serialize(input, outBuffer);
-        writeActions(ApplyActionsCase.class.cast(input).getApplyActions(),
-                EncodeConstants.OF13_VERSION_ID, outBuffer,index);
+        writeActions(input.getApplyActions(), EncodeConstants.OF13_VERSION_ID, outBuffer,index);
     }
 
     @Override
index 6e85ba56685187b585b5054eaeafe45dd4312e13..16de0297f1cd2d15385f23920a4a20795afdaf1d 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 
-public class ClearActionsInstructionSerializer extends AbstractInstructionSerializer {
+public class ClearActionsInstructionSerializer extends AbstractInstructionSerializer<Instruction> {
 
     @Override
     public void serialize(Instruction input, ByteBuf outBuffer) {
index dc0a3849df381b4da322c6e7f89cdef6003effe4..810459fab4fbba3dd4f14bd11b6a537725b5d96c 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
 
-public class GoToTableInstructionSerializer extends AbstractInstructionSerializer {
+public class GoToTableInstructionSerializer extends AbstractInstructionSerializer<GoToTableCase> {
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(GoToTableCase input, ByteBuf outBuffer) {
         super.serialize(input, outBuffer);
-        outBuffer.writeByte(GoToTableCase.class.cast(input).getGoToTable().getTableId());
+        outBuffer.writeByte(input.getGoToTable().getTableId());
         outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE);
     }
 
index 0e5e04275069d0c3115bd36de3622c01a56e40ba..f9054be85edd735e3b6eddc06fb210c700a8b786 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase;
 
-public class MeterInstructionSerializer extends AbstractInstructionSerializer {
+public class MeterInstructionSerializer extends AbstractInstructionSerializer<MeterCase> {
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(MeterCase input, ByteBuf outBuffer) {
         super.serialize(input, outBuffer);
-        outBuffer.writeInt(MeterCase.class.cast(input).getMeter().getMeterId().getValue().intValue());
+        outBuffer.writeInt(input.getMeter().getMeterId().getValue().intValue());
     }
 
     @Override
index 75561ad85cbae0bffde094afe5cc1692d4184b9e..0241ae41552109ae4154ea47c42d70bbf2440add 100644 (file)
@@ -11,17 +11,15 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
 
-public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer {
+public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer<WriteActionsCase> {
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(WriteActionsCase input, ByteBuf outBuffer) {
         int index = outBuffer.writerIndex();
         super.serialize(input, outBuffer);
-        writeActions(WriteActionsCase.class.cast(input).getWriteActions(),
-                EncodeConstants.OF13_VERSION_ID, outBuffer,index);
+        writeActions(input.getWriteActions(), EncodeConstants.OF13_VERSION_ID, outBuffer,index);
     }
 
     @Override
index 8fa8c9578cd970aa02ac5c6720427a2de5677d19..70ffc9dc1997e9b428de97f6aae00f780d70a02b 100644 (file)
@@ -12,16 +12,15 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
 
-public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer {
+public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer<WriteMetadataCase> {
 
     @Override
-    public void serialize(Instruction input, ByteBuf outBuffer) {
+    public void serialize(WriteMetadataCase input, ByteBuf outBuffer) {
         super.serialize(input, outBuffer);
-        final WriteMetadata writeMetadata = WriteMetadataCase.class.cast(input).getWriteMetadata();
+        final WriteMetadata writeMetadata = input.getWriteMetadata();
         outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
         outBuffer.writeBytes(ByteUtil
                 .convertBigIntegerToNBytes(writeMetadata.getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
index 49be46c0b487a7d6f6cd614ed4684d422b0d2029..e658c40a5bf826f666f8105b7378b6652dd1220d 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.protocol.serialization.messages;
 
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -164,8 +165,8 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
      * @param outBuffer output buffer
      */
     private void writeMatch(final FlowMessage message, final ByteBuf outBuffer) {
-        registry.<Match, OFSerializer<Match>>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class))
-                .serialize(message.getMatch(), outBuffer);
+        Preconditions.checkNotNull(registry).<Match, OFSerializer<Match>>getSerializer(
+                new MessageTypeKey<>(message.getVersion(), Match.class)).serialize(message.getMatch(), outBuffer);
 
     }
 
index 838bf806666a9d1084944a13b96597fb06a6019a..9be1f02f7c57b6590cfae0f30aa18d1bab53e328 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.util.Optional;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
@@ -20,25 +21,20 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
 import org.opendaylight.openflowplugin.extension.api.exception.ConversionException;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.request.multipart.request.body.MultipartRequestExperimenter;
 
-public class MultipartRequestExperimenterSerializer implements OFSerializer<MultipartRequestBody>,
+public class MultipartRequestExperimenterSerializer implements OFSerializer<MultipartRequestExperimenter>,
         SerializerRegistryInjector {
 
     private SerializerRegistry registry;
 
     @Override
     @SuppressWarnings("unchecked")
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestExperimenter multipartRequestExperimenter = MultipartRequestExperimenter
-                .class
-                .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestExperimenter multipartRequestExperimenter, final ByteBuf byteBuf) {
         try {
-            final OFSerializer<ExperimenterMessageOfChoice> serializer = registry
+            final OFSerializer<ExperimenterMessageOfChoice> serializer = Preconditions.checkNotNull(registry)
                     .getSerializer(new MessageTypeKey<>(
                             EncodeConstants.OF13_VERSION_ID,
                             multipartRequestExperimenter.getExperimenterMessageOfChoice().getImplementedInterface()));
@@ -52,7 +48,7 @@ public class MultipartRequestExperimenterSerializer implements OFSerializer<Mult
                                     .getExperimenterMessageOfChoice().getImplementedInterface(),
                             OFConstants.OFP_VERSION_1_3)))
                     .ifPresent(converter -> {
-                        final OFSerializer<ExperimenterDataOfChoice> serializer = registry
+                        final OFSerializer<ExperimenterDataOfChoice> serializer = Preconditions.checkNotNull(registry)
                                 .getSerializer(ExperimenterSerializerKeyFactory
                                         .createMultipartRequestSerializerKey(
                                                 EncodeConstants.OF13_VERSION_ID,
index 9c6cb9ba39905ce9d67309458029c797a43ae11c..284026b55433cd1812d937348e366237532a8768 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart;
 
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -19,9 +20,8 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 
-public class MultipartRequestFlowAggregateStatsSerializer implements OFSerializer<MultipartRequestBody>,
+public class MultipartRequestFlowAggregateStatsSerializer implements OFSerializer<MultipartRequestFlowAggregateStats>,
         SerializerRegistryInjector {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3;
@@ -29,11 +29,8 @@ public class MultipartRequestFlowAggregateStatsSerializer implements OFSerialize
     private SerializerRegistry registry;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestFlowAggregateStats multipartRequestFlowAggregateStats = MultipartRequestFlowAggregateStats
-                .class
-                .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestFlowAggregateStats multipartRequestFlowAggregateStats,
+            final ByteBuf byteBuf) {
         byteBuf.writeByte(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getTableId(),
                 OFConstants.OFPTT_ALL).byteValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01);
@@ -47,7 +44,7 @@ public class MultipartRequestFlowAggregateStatsSerializer implements OFSerialize
         byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getCookieMask(),
                 new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).getValue().longValue());
 
-        registry.<Match, OFSerializer<Match>>getSerializer(
+        Preconditions.checkNotNull(registry).<Match, OFSerializer<Match>>getSerializer(
                 new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class))
                 .serialize(multipartRequestFlowAggregateStats.getMatch(), byteBuf);
     }
index e2fef3a1a16e7b2a614b604655bc2ccac0c25240..50dd3ba14920f6a4ad4e76af67299e6a6db24352 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart;
 
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -19,9 +20,8 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 
-public class MultipartRequestFlowStatsSerializer implements OFSerializer<MultipartRequestBody>,
+public class MultipartRequestFlowStatsSerializer implements OFSerializer<MultipartRequestFlowStats>,
         SerializerRegistryInjector {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3;
@@ -29,11 +29,7 @@ public class MultipartRequestFlowStatsSerializer implements OFSerializer<Multipa
     private SerializerRegistry registry;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestFlowStats multipartRequestFlowStats = MultipartRequestFlowStats
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestFlowStats multipartRequestFlowStats, final ByteBuf byteBuf) {
         byteBuf.writeByte(MoreObjects.firstNonNull(multipartRequestFlowStats.getTableId(),
                 OFConstants.OFPTT_ALL).byteValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01);
@@ -47,7 +43,7 @@ public class MultipartRequestFlowStatsSerializer implements OFSerializer<Multipa
         byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowStats.getCookieMask(),
                 new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).getValue().longValue());
 
-        registry.<Match, OFSerializer<Match>>getSerializer(
+        Preconditions.checkNotNull(registry).<Match, OFSerializer<Match>>getSerializer(
             new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class))
             .serialize(multipartRequestFlowStats.getMatch(), byteBuf);
     }
index b6999961bdcdfffc45fd4f534ed95c081518f2cb..e9d38d220b076cc9301320c712c13f36e1abdfbf 100644 (file)
@@ -14,18 +14,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 
-public class MultipartRequestGroupStatsSerializer implements OFSerializer<MultipartRequestBody> {
+public class MultipartRequestGroupStatsSerializer implements OFSerializer<MultipartRequestGroupStats> {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestGroupStats multipartRequestGroupStats = MultipartRequestGroupStats
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestGroupStats multipartRequestGroupStats, final ByteBuf byteBuf) {
         byteBuf.writeInt(MoreObjects
             .firstNonNull(multipartRequestGroupStats.getGroupId(), new GroupId(OFConstants.OFPG_ALL))
             .getValue().intValue());
index 272d2b138a9fce3316f50cb879765c7f3b47b0fd..1034d611a84f85a3c7621dee1e8d8fb4a5a07188 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.util.Objects;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
@@ -53,7 +54,7 @@ public class MultipartRequestMessageSerializer extends AbstractMessageSerializer
         outBuffer.writeShort(ByteBufUtils.fillBitMask(0, message.isRequestMore()));
         outBuffer.writeZero(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
 
-        final OFSerializer<MultipartRequestBody> serializer = registry
+        final OFSerializer<MultipartRequestBody> serializer = Preconditions.checkNotNull(registry)
             .getSerializer(new MessageTypeKey<>(
                 EncodeConstants.OF13_VERSION_ID,
                 multipartRequestBody.getImplementedInterface()));
index 19bbc5a8e0e4a166e20dbe838e988498759b59b1..428892857654efedd58219b06a597916f405a258 100644 (file)
@@ -14,18 +14,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 
-public class MultipartRequestMeterConfigSerializer implements OFSerializer<MultipartRequestBody> {
+public class MultipartRequestMeterConfigSerializer implements OFSerializer<MultipartRequestMeterConfig> {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestMeterConfig multipartRequestMeterConfig = MultipartRequestMeterConfig
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestMeterConfig multipartRequestMeterConfig, final ByteBuf byteBuf) {
         byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestMeterConfig.getMeterId(),
                 new MeterId(OFConstants.OFPM_ALL)).getValue().intValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY);
index e9dca48dcffab9879e2a2238a5580fdb494ac429..4230f24d35812bc5202fe1ef78a387925bbff26f 100644 (file)
@@ -14,18 +14,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 
-public class MultipartRequestMeterStatsSerializer implements OFSerializer<MultipartRequestBody> {
+public class MultipartRequestMeterStatsSerializer implements OFSerializer<MultipartRequestMeterStats> {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestMeterStats multipartRequestMeterStats = MultipartRequestMeterStats
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestMeterStats multipartRequestMeterStats, final ByteBuf byteBuf) {
         byteBuf.writeInt(MoreObjects
             .firstNonNull(multipartRequestMeterStats.getMeterId(), new MeterId(OFConstants.OFPM_ALL))
                 .getValue().intValue());
index a4a0a3704731d5e79295e6529ec3481332f715c1..933499a33f9a11159e626fb300a27137ad7b9e5f 100644 (file)
@@ -14,19 +14,14 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats;
 
-public class MultipartRequestPortStatsSerializer implements OFSerializer<MultipartRequestBody> {
+public class MultipartRequestPortStatsSerializer implements OFSerializer<MultipartRequestPortStats> {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestPortStats multipartRequestPortStats = MultipartRequestPortStats
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestPortStats multipartRequestPortStats, final ByteBuf byteBuf) {
         if (Objects.isNull(multipartRequestPortStats.getNodeConnectorId())) {
             byteBuf.writeInt(OFConstants.OFPP_ANY.intValue());
         } else {
index 9820624faae848c6bef762845b18b790bf0157ad..5cfb622d0c5b76902ca1795fe940eacfeb7a304c 100644 (file)
@@ -16,17 +16,12 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats;
 
-public class MultipartRequestQueueStatsSerializer implements OFSerializer<MultipartRequestBody> {
+public class MultipartRequestQueueStatsSerializer implements OFSerializer<MultipartRequestQueueStats> {
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestQueueStats multipartRequestQueueStats = MultipartRequestQueueStats
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestQueueStats multipartRequestQueueStats, final ByteBuf byteBuf) {
         if (Objects.isNull(multipartRequestQueueStats.getNodeConnectorId())) {
             byteBuf.writeInt(OFConstants.OFPP_ANY.intValue());
         } else {
index c184952d3ddc994eab665a1b671c6f7217d7b49c..e573fab5bbec603d9b2680fe65c6f55aa0472495 100644 (file)
@@ -8,7 +8,9 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
+import java.nio.charset.StandardCharsets;
 import java.util.Objects;
 import java.util.Optional;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
@@ -17,23 +19,18 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegist
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
 
-public class MultipartRequestTableFeaturesSerializer implements OFSerializer<MultipartRequestBody>,
+public class MultipartRequestTableFeaturesSerializer implements OFSerializer<MultipartRequestTableFeatures>,
         SerializerRegistryInjector {
 
     private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5;
     private SerializerRegistry registry;
 
     @Override
-    public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) {
-        final MultipartRequestTableFeatures multipartRequestTableFeatures = MultipartRequestTableFeatures
-            .class
-            .cast(multipartRequestBody);
-
+    public void serialize(final MultipartRequestTableFeatures multipartRequestTableFeatures, final ByteBuf byteBuf) {
         Optional
             .ofNullable(multipartRequestTableFeatures.getTableFeatures())
             .ifPresent(tableFeatures -> tableFeatures
@@ -44,8 +41,8 @@ public class MultipartRequestTableFeaturesSerializer implements OFSerializer<Mul
                     byteBuf.writeShort(EncodeConstants.EMPTY_LENGTH);
                     byteBuf.writeByte(tableFeature.getTableId().byteValue());
                     byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY);
-                    byteBuf.writeBytes(tableFeature.getName().getBytes());
-                    byteBuf.writeZero(32 - tableFeature.getName().getBytes().length);
+                    byteBuf.writeBytes(tableFeature.getName().getBytes(StandardCharsets.UTF_8));
+                    byteBuf.writeZero(32 - tableFeature.getName().getBytes(StandardCharsets.UTF_8).length);
                     byteBuf.writeLong(tableFeature.getMetadataMatch().longValue());
                     byteBuf.writeLong(tableFeature.getMetadataWrite().longValue());
                     byteBuf.writeInt(ByteBufUtils.fillBitMask(0, tableFeature.getConfig().isDEPRECATEDMASK()));
@@ -68,9 +65,10 @@ public class MultipartRequestTableFeaturesSerializer implements OFSerializer<Mul
                         .getTableFeaturePropType()
                         .getImplementedInterface();
 
-                    registry.<TableFeaturePropType, OFSerializer<TableFeaturePropType>>getSerializer(
+                    Preconditions.checkNotNull(registry)
+                        .<TableFeaturePropType, OFSerializer<TableFeaturePropType>>getSerializer(
                             new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, clazz))
-                        .serialize(property.getTableFeaturePropType(), byteBuf);
+                                .serialize(property.getTableFeaturePropType(), byteBuf);
                 }));
     }
 
index 312db2f5f37358decdca04ef8a783d6972f71ce9..8d79ffcea8539cc39f0e8da7cff43193aaf7789a 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -29,7 +30,7 @@ public class ApplySetfieldMissTablePropertySerializer extends
         property
             .getApplySetfieldMiss()
             .getSetFieldMatch()
-            .forEach(setFieldMatch -> registry
+            .forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
                 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
                     new MessageTypeKey<>(
                         EncodeConstants.OF13_VERSION_ID,
index a16f2d215562ccf8361b610761d4668d7d44c3bf..0d09e54b5c98e40d51b4cf3a2eed9a68ea16c6b9 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -29,7 +30,7 @@ public class ApplySetfieldTablePropertySerializer extends AbstractTablePropertyS
         property
             .getApplySetfield()
             .getSetFieldMatch()
-            .forEach(setFieldMatch -> registry
+            .forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
                 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
                     new MessageTypeKey<>(
                         EncodeConstants.OF13_VERSION_ID,
index 4012f00571c460f868270debf23716191b34f657..55de662876dc4ada38d9042ada69ff408ff71414 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -29,7 +30,7 @@ public class MatchTablePropertySerializer extends AbstractTablePropertySerialize
         property
             .getMatchSetfield()
             .getSetFieldMatch()
-            .forEach(setFieldMatch -> registry
+            .forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
                 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
                     new MessageTypeKey<>(
                         EncodeConstants.OF13_VERSION_ID,
index 500d89f67cbb217467978f37bf7f227519aa6d98..f7f24aa1de9071969dc187e79fb39cf9a07c0421 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -29,7 +30,7 @@ public class WildcardsTablePropertySerializer extends AbstractTablePropertySeria
         property
             .getWildcardSetfield()
             .getSetFieldMatch()
-            .forEach(setFieldMatch -> registry
+            .forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
                 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
                     new MessageTypeKey<>(
                         EncodeConstants.OF13_VERSION_ID,
index 39a1d4ac949395dd9ee3b3b35efee98127f7f514..02f7e34e81e871c58f189f23ada440e1cf1676f9 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -29,7 +30,7 @@ public class WriteSetfieldMissTablePropertySerializer extends
         property
             .getWriteSetfieldMiss()
             .getSetFieldMatch()
-            .forEach(setFieldMatch -> registry
+            .forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
                 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
                     new MessageTypeKey<>(
                         EncodeConstants.OF13_VERSION_ID,
index b3605e7a8f8bb19fd5878a59eee96cd84995af7b..fe571b6200f21a41da180bb753b69f41e1a4b090 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
@@ -29,7 +30,7 @@ public class WriteSetfieldTablePropertySerializer extends AbstractTablePropertyS
         property
             .getWriteSetfield()
             .getSetFieldMatch()
-            .forEach(setFieldMatch -> registry
+            .forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
                 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
                     new MessageTypeKey<>(
                         EncodeConstants.OF13_VERSION_ID,
index 98ae77254705e09dfc0256abc70b2cd4974d43c3..8fe0dfd6506826b1972ebe3e0dc00afe6175870d 100644 (file)
@@ -51,7 +51,7 @@ public final class ActionUtil {
             Optional.ofNullable(OFSessionUtil.getExtensionConvertorProvider())
                     .flatMap(provider ->
                             (GeneralExtensionGrouping.class.isInstance(action)
-                                    ? convertExtensionGrouping(provider, action, version)
+                                    ? convertExtensionGrouping(provider, (GeneralExtensionGrouping)action, version)
                                     : convertGenericAction(provider, action, version))
                                     .map(ofjAction -> {
                                         final OFSerializer<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
@@ -90,7 +90,7 @@ public final class ActionUtil {
             Optional.ofNullable(OFSessionUtil.getExtensionConvertorProvider())
                     .flatMap(provider ->
                             (GeneralExtensionGrouping.class.isInstance(action)
-                                    ? convertExtensionGrouping(provider, action, version)
+                                    ? convertExtensionGrouping(provider, (GeneralExtensionGrouping)action, version)
                                     : convertGenericAction(provider, action, version))
                                     .map(ofjAction -> {
                                         final HeaderSerializer<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
@@ -123,21 +123,21 @@ public final class ActionUtil {
      * to OpenFlowJava action
      *
      * @param provider extension converter provider
-     * @param action   OpenFlowPlugin action
+     * @param action   GeneralExtensionGrouping action
      * @param version  OpenFlow version
      * @return optional OpenFlowJava action
      */
     private static Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions
             .grouping.Action> convertExtensionGrouping(final ExtensionConverterProvider provider,
-                                                       final Action action,
+                                                       final GeneralExtensionGrouping action,
                                                        final short version) {
         final ConverterExtensionKey<? extends ExtensionKey> key =
-                new ConverterExtensionKey<>(GeneralExtensionGrouping.class.cast(action).getExtensionKey(), version);
+                new ConverterExtensionKey<>(action.getExtensionKey(), version);
 
         final ConvertorToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions
                 .grouping.Action> converter = provider.getConverter(key);
 
-        return Optional.ofNullable(converter).map(c -> c.convert(((GeneralExtensionGrouping) action).getExtension()));
+        return Optional.ofNullable(converter).map(c -> c.convert(action.getExtension()));
     }
 
     /**
index 0c3b65e92012d49058f1ef04af73649b3a273246..67e113edf7fe11adca681668d39fe4d9a0b987a4 100644 (file)
@@ -127,7 +127,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
         Futures.addCallback(future, new FutureCallback<Optional<FlowCapableNode>>() {
             @Override
-            public void onSuccess(Optional<FlowCapableNode> result) {
+            public void onSuccess(@Nonnull Optional<FlowCapableNode> result) {
                 result.asSet().stream()
                         .filter(Objects::nonNull)
                         .filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable()))
index 164e6ce153cdd15dcaf813144c310387b1a75097..c162662b9fecdeca6f0744c357128e97b87e4ecf 100644 (file)
@@ -16,6 +16,7 @@ import java.math.BigInteger;
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -68,7 +69,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
                 handleServiceCall(roleRequestInputBuilder);
         Futures.addCallback(genIdListenableFuture, new FutureCallback<RpcResult<RoleRequestOutput>>() {
             @Override
-            public void onSuccess(final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
+            public void onSuccess(@Nonnull final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
                 if (roleRequestOutputRpcResult.isSuccessful()) {
                     final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
                     if (roleRequestOutput != null) {
@@ -114,7 +115,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
         final SettableFuture<RpcResult<SetRoleOutput>> finalFuture = SettableFuture.create();
         Futures.addCallback(roleListenableFuture, new FutureCallback<RpcResult<RoleRequestOutput>>() {
             @Override
-            public void onSuccess(final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
+            public void onSuccess(@Nonnull final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
                 LOG.info("submitRoleChange onSuccess for device:{}, role:{}",
                         getDeviceInfo().getNodeId(), ofpRole);
                 final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
index daa667cf2e3452162cff2e0e1d88389a8c2eec82..9df13053dab82773be9a49f14226ca49620548a0 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
@@ -132,7 +133,7 @@ public final class FlatBatchFlowAdapters {
         return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
             @Nullable
             @Override
-            public RpcResult<ProcessFlatBatchOutput> apply(@Nullable final RpcResult<T> input) {
+            public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
                 List<BatchFailure> batchFailures = wrapBatchFlowFailuresForFlat(input, stepOffset);
                 ProcessFlatBatchOutputBuilder outputBuilder =
                         new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
index 747f104d94da1590b36436d5df001d82995c9e55..38efda6b60b90ed1dd6b231bd580064b96cd72f2 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
@@ -131,7 +132,7 @@ public final class FlatBatchGroupAdapters {
         return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
             @Nullable
             @Override
-            public RpcResult<ProcessFlatBatchOutput> apply(@Nullable final RpcResult<T> input) {
+            public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
                 List<BatchFailure> batchFailures = wrapBatchGroupFailuresForFlat(input, stepOffset);
                 ProcessFlatBatchOutputBuilder outputBuilder =
                         new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
index c29ff2b1dbead4c159f4415150c33dc934a6d981..07b92046d88cddf335a0e89293ae941a861c6657 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
@@ -131,7 +132,7 @@ public final class FlatBatchMeterAdapters {
         return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
             @Nullable
             @Override
-            public RpcResult<ProcessFlatBatchOutput> apply(@Nullable final RpcResult<T> input) {
+            public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
                 List<BatchFailure> batchFailures = wrapBatchMeterFailuresForFlat(input, stepOffset);
                 ProcessFlatBatchOutputBuilder outputBuilder =
                         new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
index 2daac9636ba6d3d9032aa134af996698c6a9d0ff..fc23fad771d73a326923cf5f976884c09c433133 100644 (file)
@@ -18,6 +18,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -99,7 +100,7 @@ public class MultiLayerExperimenterMultipartService extends AbstractExperimenter
 
         class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
             @Override
-            public void onSuccess(final RpcResult<List<MultipartReply>> result) {
+            public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
                 if (result.isSuccessful()) {
                     final List<MultipartReply> multipartReplies = result.getResult();
                     if (multipartReplies.isEmpty()) {
index 9797e4ed0aa3e1700b543d4814f2c5cda58a9d36..10d88f9a5773ecb84bb9830d8cb5dedfb1221a2c 100644 (file)
@@ -16,6 +16,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -69,7 +70,7 @@ public final class MultiLayerFlowService<O extends DataObject> extends AbstractS
         final SettableFuture<RpcResult<O>> finalFuture = SettableFuture.create();
         Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<O>>>() {
             @Override
-            public void onSuccess(final List<RpcResult<O>> results) {
+            public void onSuccess(@Nonnull final List<RpcResult<O>> results) {
                 final ArrayList<RpcError> errors = new ArrayList();
                 for (RpcResult<O> flowModResult : results) {
                     if (flowModResult == null) {
index de51bc3e1823cedf677eec88b7a0f825e1fdf322..aa4d9291155ea91e1fdf00ed70120c34a10fe78a 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -88,7 +89,7 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
         class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
             @Override
             @SuppressWarnings("checkstyle:IllegalCatch")
-            public void onSuccess(final RpcResult<List<MultipartReply>> result) {
+            public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
 
                 if (result.isSuccessful()) {
                     final List<MultipartReply> multipartReplies = result.getResult();
@@ -143,7 +144,7 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
                 final MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
                 if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
                     final MultipartReplyTableFeaturesCase tableFeaturesCase =
-                            ((MultipartReplyTableFeaturesCase) multipartReplyBody);
+                            (MultipartReplyTableFeaturesCase) multipartReplyBody;
                     final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
                             .getMultipartReplyTableFeatures();
 
index 8eee2f0ba92893ad61ccfc4acd756a90eb2a6536..3c30cc8509df77985b4606eb02b147c4f44c9567 100644 (file)
@@ -18,6 +18,7 @@ import com.google.common.util.concurrent.SettableFuture;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SalExperimenterMessageService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput;
@@ -80,7 +81,7 @@ public class SalBundleServiceImpl implements SalBundleService {
         final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
         Futures.addCallback(Futures.successfulAsList(partialResults), new FutureCallback<List<RpcResult<Void>>>() {
             @Override
-            public void onSuccess(List<RpcResult<Void>> results) {
+            public void onSuccess(@Nonnull List<RpcResult<Void>> results) {
                 final ArrayList<RpcError> errors = new ArrayList<>();
                 final RpcResultBuilder<Void> rpcResultBuilder;
                 for (RpcResult<Void> res : results) {
@@ -107,4 +108,4 @@ public class SalBundleServiceImpl implements SalBundleService {
         }, MoreExecutors.directExecutor());
         return result;
     }
-}
\ No newline at end of file
+}
index e8c71242cd4ecf56fd26659efe19a121761d83ec..f0f9c91438ed1e7abcb43913087deaf7f04901c4 100644 (file)
@@ -7,13 +7,11 @@
  */
 package org.opendaylight.openflowplugin.impl.services.sal;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.concurrent.Future;
-import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.impl.services.EchoService;
@@ -43,26 +41,20 @@ public final class SalEchoServiceImpl implements SalEchoService {
 
     private Future<RpcResult<SendEchoOutput>>
             transform(final ListenableFuture<RpcResult<EchoOutput>> rpcResultListenableFuture) {
-        return Futures.transform(rpcResultListenableFuture,
-                                 new Function<RpcResult<EchoOutput>,
-                                 RpcResult<SendEchoOutput>>() {
-                @Nullable
-                @Override
-                public RpcResult<SendEchoOutput> apply(@Nullable final RpcResult<EchoOutput> input) {
-                    Preconditions.checkNotNull(input, "echoOutput value is never expected to be NULL");
-                    final RpcResult<SendEchoOutput> rpcOutput;
-                    if (input.isSuccessful()) {
-                        final SendEchoOutput sendEchoOutput = new SendEchoOutputBuilder()
-                                .setData(input.getResult().getData())
-                                .build();
-                        rpcOutput = RpcResultBuilder.success(sendEchoOutput).build();
-                    } else {
-                        rpcOutput = RpcResultBuilder.<SendEchoOutput>failed()
-                                .withRpcErrors(input.getErrors())
-                                .build();
-                    }
-                    return rpcOutput;
-                }
-            }, MoreExecutors.directExecutor());
+        return Futures.transform(rpcResultListenableFuture, input -> {
+            Preconditions.checkNotNull(input, "echoOutput value is never expected to be NULL");
+            final RpcResult<SendEchoOutput> rpcOutput;
+            if (input.isSuccessful()) {
+                final SendEchoOutput sendEchoOutput = new SendEchoOutputBuilder()
+                        .setData(input.getResult().getData())
+                        .build();
+                rpcOutput = RpcResultBuilder.success(sendEchoOutput).build();
+            } else {
+                rpcOutput = RpcResultBuilder.<SendEchoOutput>failed()
+                        .withRpcErrors(input.getErrors())
+                        .build();
+            }
+            return rpcOutput;
+        }, MoreExecutors.directExecutor());
     }
 }
index fa644af383204818d66758af8d50228f356544d6..73e5670c73923416bf134d28b8ecca01bb40a8c3 100644 (file)
@@ -16,6 +16,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -134,7 +135,7 @@ public class SalFlowServiceImpl implements SalFlowService {
 
                 Futures.addCallback(listListenableFuture, new FutureCallback<List<RpcResult<UpdateFlowOutput>>>() {
                     @Override
-                    public void onSuccess(final List<RpcResult<UpdateFlowOutput>> results) {
+                    public void onSuccess(@Nonnull final List<RpcResult<UpdateFlowOutput>> results) {
                         final ArrayList<RpcError> errors = new ArrayList();
                         for (RpcResult<UpdateFlowOutput> flowModResult : results) {
                             if (flowModResult == null) {
@@ -202,7 +203,7 @@ public class SalFlowServiceImpl implements SalFlowService {
         }
 
         @Override
-        public void onSuccess(final RpcResult<AddFlowOutput> rpcResult) {
+        public void onSuccess(@Nonnull final RpcResult<AddFlowOutput> rpcResult) {
             if (rpcResult.isSuccessful()) {
                 final FlowDescriptor flowDescriptor;
 
@@ -240,7 +241,7 @@ public class SalFlowServiceImpl implements SalFlowService {
         }
 
         @Override
-        public void onSuccess(final RpcResult<RemoveFlowOutput> result) {
+        public void onSuccess(@Nonnull final RpcResult<RemoveFlowOutput> result) {
             if (result.isSuccessful()) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Flow remove finished without error for flow={}", input);
@@ -270,7 +271,7 @@ public class SalFlowServiceImpl implements SalFlowService {
         }
 
         @Override
-        public void onSuccess(final RpcResult<UpdateFlowOutput> updateFlowOutputRpcResult) {
+        public void onSuccess(@Nonnull final RpcResult<UpdateFlowOutput> updateFlowOutputRpcResult) {
             final DeviceFlowRegistry deviceFlowRegistry = deviceContext.getDeviceFlowRegistry();
 
             final UpdatedFlow updated = input.getUpdatedFlow();
index 042e5a8cd22854733f1b26f2f47803fdcff9df62..60898e7ed459219ef83a26d852255b2371696475 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerGroupService;
@@ -74,7 +75,7 @@ public class SalGroupServiceImpl implements SalGroupService {
 
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddGroupOutput>>() {
             @Override
-            public void onSuccess(RpcResult<AddGroupOutput> result) {
+            public void onSuccess(@Nonnull RpcResult<AddGroupOutput> result) {
                 if (result.isSuccessful()) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Group add with id={} finished without error", input.getGroupId().getValue());
@@ -108,7 +109,7 @@ public class SalGroupServiceImpl implements SalGroupService {
 
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<UpdateGroupOutput>>() {
             @Override
-            public void onSuccess(RpcResult<UpdateGroupOutput> result) {
+            public void onSuccess(@Nonnull RpcResult<UpdateGroupOutput> result) {
                 if (result.isSuccessful()) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Group update with original id={} finished without error",
@@ -139,7 +140,7 @@ public class SalGroupServiceImpl implements SalGroupService {
 
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<RemoveGroupOutput>>() {
             @Override
-            public void onSuccess(RpcResult<RemoveGroupOutput> result) {
+            public void onSuccess(@Nonnull RpcResult<RemoveGroupOutput> result) {
                 if (result.isSuccessful()) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Group remove with id={} finished without error", input.getGroupId().getValue());
index e1b5a0f7aab224929a09628d7a10675be047fc8a..5e18e5bffbe57bf8a8e1872cbce9f5c31fa9d582 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerMeterService;
@@ -74,7 +75,7 @@ public class SalMeterServiceImpl implements SalMeterService {
 
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddMeterOutput>>() {
             @Override
-            public void onSuccess(RpcResult<AddMeterOutput> result) {
+            public void onSuccess(@Nonnull RpcResult<AddMeterOutput> result) {
                 if (result.isSuccessful()) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Meter add with id={} finished without error", input.getMeterId());
@@ -106,7 +107,7 @@ public class SalMeterServiceImpl implements SalMeterService {
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<UpdateMeterOutput>>() {
 
             @Override
-            public void onSuccess(RpcResult<UpdateMeterOutput> result) {
+            public void onSuccess(@Nonnull RpcResult<UpdateMeterOutput> result) {
                 if (result.isSuccessful()) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Meter update with id={} finished without error",
@@ -137,7 +138,7 @@ public class SalMeterServiceImpl implements SalMeterService {
 
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<RemoveMeterOutput>>() {
             @Override
-            public void onSuccess(RpcResult<RemoveMeterOutput> result) {
+            public void onSuccess(@Nonnull RpcResult<RemoveMeterOutput> result) {
                 if (result.isSuccessful()) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Meter remove with id={} finished without error", input.getMeterId());
index 7bb135e96acc7b3a684e947ebf5bb2c354ce3dab..ef44bd52de900b9e2d4cd7a5a1035ab4d18b4c5e 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.util.concurrent.SettableFuture;
 import java.util.List;
 import java.util.concurrent.Future;
 import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -60,7 +61,7 @@ public class SingleLayerExperimenterMultipartService extends AbstractExperimente
 
         Futures.addCallback(handleServiceCall(input), new FutureCallback<RpcResult<List<MultipartReply>>>() {
             @Override
-            public void onSuccess(final RpcResult<List<MultipartReply>> result) {
+            public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
                 if (result.isSuccessful()) {
                     future.set(RpcResultBuilder
                         .success(new SendExperimenterMpRequestOutputBuilder()
index 567213447fe393aba980d194ac6f4c2666964a1f..e91ad820b255fc6618870e66ce06f383e2d283e9 100644 (file)
@@ -16,6 +16,7 @@ import java.math.BigInteger;
 import java.util.List;
 import java.util.concurrent.Future;
 import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -66,7 +67,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
         Futures.addCallback(handleServiceCall(input), new FutureCallback<RpcResult<List<MultipartReply>>>() {
             @Override
             @SuppressWarnings("checkstyle:IllegalCatch")
-            public void onSuccess(final RpcResult<List<MultipartReply>> result) {
+            public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
                 if (result.isSuccessful()) {
                     final List<MultipartReply> multipartReplies = result.getResult();
                     if (multipartReplies.isEmpty()) {
@@ -113,4 +114,4 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
 
         return finalFuture;
     }
-}
\ No newline at end of file
+}
index 61fd206c2fbe4f0ea7474cadfe3bdb6b10f5aac1..9138ed1edf032fdc3d85ebf138c3106aecd9a188 100644 (file)
@@ -227,7 +227,7 @@ class StatisticsContextImpl<T extends OfHeader> implements StatisticsContext {
             // write end timestamp to state snapshot container
             Futures.addCallback(newDataGathering, new FutureCallback<Boolean>() {
                 @Override
-                public void onSuccess(final Boolean result) {
+                public void onSuccess(@Nonnull final Boolean result) {
                     StatisticsGatheringUtils.markDeviceStateSnapshotEnd(deviceInfo, deviceContext, result);
                 }
 
index ef18232d565848e8e0acd8afeb89d4b65b505bc3..1a1801520f0cfb475b3d72a961a275bc93f05914 100644 (file)
@@ -24,7 +24,6 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutput;
@@ -47,7 +46,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     private final Semaphore workModeGuard = new Semaphore(1, true);
     private final BindingAwareBroker.RpcRegistration<StatisticsManagerControlService> controlServiceRegistration;
     private final ListeningExecutorService executorService;
-    private StatisticsWorkMode workMode = StatisticsWorkMode.COLLECTALL;
+    private final StatisticsWorkMode workMode = StatisticsWorkMode.COLLECTALL;
     private boolean isStatisticsFullyDisabled;
 
     public StatisticsManagerImpl(@Nonnull final OpenflowProviderConfig config,
@@ -103,27 +102,15 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         final MultipartWriterProvider statisticsWriterProvider = MultipartWriterProviderFactory
                 .createDefaultProvider(deviceContext);
 
-        final StatisticsContext statisticsContext =
-                deviceContext.canUseSingleLayerSerialization()
-                        ? new StatisticsContextImpl<MultipartReply>(
-                                deviceContext,
-                                converterExecutor,
-                                statisticsWriterProvider,
-                                executorService,
-                                !isStatisticsFullyDisabled && config.isIsStatisticsPollingOn(),
-                                useReconciliationFramework,
-                                config.getBasicTimerDelay().getValue(),
-                                config.getMaximumTimerDelay().getValue()) :
-                        new StatisticsContextImpl<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
-                                .protocol.rev130731.MultipartReply>(
-                                deviceContext,
-                                converterExecutor,
-                                statisticsWriterProvider,
-                                executorService,
-                                !isStatisticsFullyDisabled && config.isIsStatisticsPollingOn(),
-                                useReconciliationFramework,
-                                config.getBasicTimerDelay().getValue(),
-                                config.getMaximumTimerDelay().getValue());
+        final StatisticsContext statisticsContext = new StatisticsContextImpl<>(
+                deviceContext,
+                converterExecutor,
+                statisticsWriterProvider,
+                executorService,
+                !isStatisticsFullyDisabled && config.isIsStatisticsPollingOn(),
+                useReconciliationFramework,
+                config.getBasicTimerDelay().getValue(),
+                config.getMaximumTimerDelay().getValue());
 
         contexts.put(deviceContext.getDeviceInfo(), statisticsContext);
         return statisticsContext;
index fa035ca53915cd29d8a0ef786aea89a1aba22db3..bcda1a869fac27fce36896757b998baa1dd834ba 100644 (file)
@@ -19,7 +19,6 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.ConnectionException;
 
 public class StatisticsPollingService extends AbstractScheduledService {
@@ -60,7 +59,7 @@ public class StatisticsPollingService extends AbstractScheduledService {
 
         Futures.addCallback(gatheringSupplier.get(), new FutureCallback<Boolean>() {
             @Override
-            public void onSuccess(@Nullable final Boolean result) {
+            public void onSuccess(@Nonnull final Boolean result) {
                 waitFuture.complete(result);
             }
 
@@ -110,4 +109,4 @@ public class StatisticsPollingService extends AbstractScheduledService {
             }
         }
     }
-}
\ No newline at end of file
+}
index 03ecdbf6e97d465ec6dc5b4c05323150731bff83..adc8e471449789044eb05eb90af6274925751e70 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.util;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Locale;
 import java.util.Objects;
 import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
@@ -245,7 +246,7 @@ public final class AddressNormalizationUtil {
             return null;
         }
 
-        return new MacAddress(macAddress.getValue().toLowerCase());
+        return new MacAddress(macAddress.getValue().toLowerCase(Locale.ROOT));
     }
 
     /**
index a7f2a97a56ff564bba5290d123c8fdac374852b3..2ff98cbfe56c0816ee0fe6dc465a61bc224f4a6a 100644 (file)
@@ -16,7 +16,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import javax.annotation.Nullable;
+import javax.annotation.Nonnull;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
@@ -73,58 +73,43 @@ public final class FlowUtil {
      * Gather errors into collection and wrap it into {@link RpcResult} and propagate all {@link RpcError}.
      */
     public static final Function<RpcResult<List<BatchFailedFlowsOutput>>,
-                                 RpcResult<RemoveFlowsBatchOutput>> FLOW_REMOVE_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedFlowsOutput>>, RpcResult<RemoveFlowsBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<RemoveFlowsBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedFlowsOutput>> batchFlowsCumulativeResult) {
+        RpcResult<RemoveFlowsBatchOutput>> FLOW_REMOVE_TRANSFORM =
+            batchFlowsCumulativeResult -> {
                 final RemoveFlowsBatchOutput batchOutput = new RemoveFlowsBatchOutputBuilder()
                         .setBatchFailedFlowsOutput(batchFlowsCumulativeResult.getResult()).build();
 
                 final RpcResultBuilder<RemoveFlowsBatchOutput> resultBld =
                         createCumulativeRpcResult(batchFlowsCumulativeResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
 
     /**
      * Gather errors into collection and wrap it into {@link RpcResult} and propagate all {@link RpcError}.
      */
     public static final Function<RpcResult<List<BatchFailedFlowsOutput>>,
-                                 RpcResult<AddFlowsBatchOutput>> FLOW_ADD_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedFlowsOutput>>, RpcResult<AddFlowsBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<AddFlowsBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedFlowsOutput>> batchFlowsCumulativeResult) {
+        RpcResult<AddFlowsBatchOutput>> FLOW_ADD_TRANSFORM =
+            batchFlowsCumulativeResult -> {
                 final AddFlowsBatchOutput batchOutput = new AddFlowsBatchOutputBuilder()
                         .setBatchFailedFlowsOutput(batchFlowsCumulativeResult.getResult()).build();
 
                 final RpcResultBuilder<AddFlowsBatchOutput> resultBld =
                         createCumulativeRpcResult(batchFlowsCumulativeResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
 
     /**
      * Gather errors into collection and wrap it into {@link RpcResult} and propagate all {@link RpcError}.
      */
     public static final Function<RpcResult<List<BatchFailedFlowsOutput>>,
-                                 RpcResult<UpdateFlowsBatchOutput>> FLOW_UPDATE_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedFlowsOutput>>, RpcResult<UpdateFlowsBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<UpdateFlowsBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedFlowsOutput>> batchFlowsCumulativeResult) {
+        RpcResult<UpdateFlowsBatchOutput>> FLOW_UPDATE_TRANSFORM =
+            batchFlowsCumulativeResult -> {
                 final UpdateFlowsBatchOutput batchOutput = new UpdateFlowsBatchOutputBuilder()
                         .setBatchFailedFlowsOutput(batchFlowsCumulativeResult.getResult()).build();
 
                 final RpcResultBuilder<UpdateFlowsBatchOutput> resultBld =
                         createCumulativeRpcResult(batchFlowsCumulativeResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
 
     private FlowUtil() {
         throw new IllegalStateException("This class should not be instantiated.");
@@ -163,25 +148,21 @@ public final class FlowUtil {
     @VisibleForTesting
     static <T extends BatchFlowOutputListGrouping>
         Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>> createComposingFunction() {
-        return new Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>>() {
-            @Nullable
-            @Override
-            public RpcResult<T> apply(@Nullable final Pair<RpcResult<T>, RpcResult<Void>> input) {
-                final RpcResultBuilder<T> resultBld;
-                if (input.getLeft().isSuccessful() && input.getRight().isSuccessful()) {
-                    resultBld = RpcResultBuilder.success();
-                } else {
-                    resultBld = RpcResultBuilder.failed();
-                }
+        return input -> {
+            final RpcResultBuilder<T> resultBld;
+            if (input.getLeft().isSuccessful() && input.getRight().isSuccessful()) {
+                resultBld = RpcResultBuilder.success();
+            } else {
+                resultBld = RpcResultBuilder.failed();
+            }
 
-                final ArrayList<RpcError> rpcErrors = new ArrayList<>(input.getLeft().getErrors());
-                rpcErrors.addAll(input.getRight().getErrors());
-                resultBld.withRpcErrors(rpcErrors);
+            final ArrayList<RpcError> rpcErrors = new ArrayList<>(input.getLeft().getErrors());
+            rpcErrors.addAll(input.getRight().getErrors());
+            resultBld.withRpcErrors(rpcErrors);
 
-                resultBld.withResult(input.getLeft().getResult());
+            resultBld.withResult(input.getLeft().getResult());
 
-                return resultBld.build();
-            }
+            return resultBld.build();
         };
     }
 
@@ -224,43 +205,39 @@ public final class FlowUtil {
         }
 
         public Function<List<RpcResult<O>>, RpcResult<List<BatchFailedFlowsOutput>>> invoke() {
-            return new Function<List<RpcResult<O>>, RpcResult<List<BatchFailedFlowsOutput>>>() {
-                @Nullable
-                @Override
-                public RpcResult<List<BatchFailedFlowsOutput>> apply(@Nullable final List<RpcResult<O>> innerInput) {
-                    final int sizeOfFutures = innerInput.size();
-                    final int sizeOfInputBatch = inputBatchFlows.size();
-                    Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
-                            "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
-
-                    final ArrayList<BatchFailedFlowsOutput> batchFlows = new ArrayList<>(sizeOfFutures);
-                    final Iterator<? extends BatchFlowIdGrouping> batchFlowIterator = inputBatchFlows.iterator();
-
-                    Collection<RpcError> flowErrors = new ArrayList<>(sizeOfFutures);
-
-                    int batchOrder = 0;
-                    for (RpcResult<O> flowModOutput : innerInput) {
-                        final FlowId flowId = batchFlowIterator.next().getFlowId();
-
-                        if (!flowModOutput.isSuccessful()) {
-                            batchFlows.add(new BatchFailedFlowsOutputBuilder()
-                                    .setFlowId(flowId)
-                                    .setBatchOrder(batchOrder)
-                                    .build());
-                            flowErrors.addAll(flowModOutput.getErrors());
-                        }
-                        batchOrder++;
+            return (@Nonnull final List<RpcResult<O>> innerInput) -> {
+                final int sizeOfFutures = innerInput.size();
+                final int sizeOfInputBatch = inputBatchFlows.size();
+                Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
+                        "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
+
+                final ArrayList<BatchFailedFlowsOutput> batchFlows = new ArrayList<>(sizeOfFutures);
+                final Iterator<? extends BatchFlowIdGrouping> batchFlowIterator = inputBatchFlows.iterator();
+
+                Collection<RpcError> flowErrors = new ArrayList<>(sizeOfFutures);
+
+                int batchOrder = 0;
+                for (RpcResult<O> flowModOutput : innerInput) {
+                    final FlowId flowId = batchFlowIterator.next().getFlowId();
+
+                    if (!flowModOutput.isSuccessful()) {
+                        batchFlows.add(new BatchFailedFlowsOutputBuilder()
+                                .setFlowId(flowId)
+                                .setBatchOrder(batchOrder)
+                                .build());
+                        flowErrors.addAll(flowModOutput.getErrors());
                     }
+                    batchOrder++;
+                }
 
-                    final RpcResultBuilder<List<BatchFailedFlowsOutput>> resultBuilder;
-                    if (!flowErrors.isEmpty()) {
-                        resultBuilder = RpcResultBuilder.<List<BatchFailedFlowsOutput>>failed()
-                                .withRpcErrors(flowErrors).withResult(batchFlows);
-                    } else {
-                        resultBuilder = SUCCESSFUL_FLOW_OUTPUT_RPC_RESULT;
-                    }
-                    return resultBuilder.build();
+                final RpcResultBuilder<List<BatchFailedFlowsOutput>> resultBuilder;
+                if (!flowErrors.isEmpty()) {
+                    resultBuilder = RpcResultBuilder.<List<BatchFailedFlowsOutput>>failed()
+                            .withRpcErrors(flowErrors).withResult(batchFlows);
+                } else {
+                    resultBuilder = SUCCESSFUL_FLOW_OUTPUT_RPC_RESULT;
                 }
+                return resultBuilder.build();
             };
         }
     }
index 4ece325736652eddbdcb322cb9d561140980062a..9ef70858240d89d843f1107b85d3bbeaeb7f8acb 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import javax.annotation.Nullable;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
@@ -50,19 +49,13 @@ public final class GroupUtil {
             RpcResultBuilder.success(Collections.<BatchFailedGroupsOutput>emptyList());
 
     public static final Function<RpcResult<List<BatchFailedGroupsOutput>>, RpcResult<AddGroupsBatchOutput>>
-        GROUP_ADD_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedGroupsOutput>>, RpcResult<AddGroupsBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<AddGroupsBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedGroupsOutput>> batchGroupsCumulatedResult) {
-                final AddGroupsBatchOutput batchOutput = new AddGroupsBatchOutputBuilder()
-                        .setBatchFailedGroupsOutput(batchGroupsCumulatedResult.getResult()).build();
+        GROUP_ADD_TRANSFORM = batchGroupsCumulatedResult -> {
+            final AddGroupsBatchOutput batchOutput = new AddGroupsBatchOutputBuilder()
+                    .setBatchFailedGroupsOutput(batchGroupsCumulatedResult.getResult()).build();
 
-                final RpcResultBuilder<AddGroupsBatchOutput> resultBld =
-                        createCumulativeRpcResult(batchGroupsCumulatedResult, batchOutput);
-                return resultBld.build();
-            }
+            final RpcResultBuilder<AddGroupsBatchOutput> resultBld =
+                    createCumulativeRpcResult(batchGroupsCumulatedResult, batchOutput);
+            return resultBld.build();
         };
     public static final Function<Pair<RpcResult<AddGroupsBatchOutput>,
                                  RpcResult<Void>>,
@@ -71,19 +64,14 @@ public final class GroupUtil {
 
     public static final Function<RpcResult<List<BatchFailedGroupsOutput>>, RpcResult<RemoveGroupsBatchOutput>>
         GROUP_REMOVE_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedGroupsOutput>>, RpcResult<RemoveGroupsBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<RemoveGroupsBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedGroupsOutput>> batchGroupsCumulatedResult) {
+            batchGroupsCumulatedResult -> {
                 final RemoveGroupsBatchOutput batchOutput = new RemoveGroupsBatchOutputBuilder()
                         .setBatchFailedGroupsOutput(batchGroupsCumulatedResult.getResult()).build();
 
                 final RpcResultBuilder<RemoveGroupsBatchOutput> resultBld =
                         createCumulativeRpcResult(batchGroupsCumulatedResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
     public static final Function<Pair<RpcResult<RemoveGroupsBatchOutput>,
                                       RpcResult<Void>>,
                                       RpcResult<RemoveGroupsBatchOutput>>
@@ -91,19 +79,14 @@ public final class GroupUtil {
 
     public static final Function<RpcResult<List<BatchFailedGroupsOutput>>, RpcResult<UpdateGroupsBatchOutput>>
         GROUP_UPDATE_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedGroupsOutput>>, RpcResult<UpdateGroupsBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<UpdateGroupsBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedGroupsOutput>> batchGroupsCumulatedResult) {
+            batchGroupsCumulatedResult -> {
                 final UpdateGroupsBatchOutput batchOutput = new UpdateGroupsBatchOutputBuilder()
                         .setBatchFailedGroupsOutput(batchGroupsCumulatedResult.getResult()).build();
 
                 final RpcResultBuilder<UpdateGroupsBatchOutput> resultBld =
                         createCumulativeRpcResult(batchGroupsCumulatedResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
     public static final Function<Pair<RpcResult<UpdateGroupsBatchOutput>,
                                       RpcResult<Void>>,
                                       RpcResult<UpdateGroupsBatchOutput>>
@@ -183,25 +166,21 @@ public final class GroupUtil {
     @VisibleForTesting
     static <T extends BatchGroupOutputListGrouping> Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>>
         createComposingFunction() {
-        return new Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>>() {
-            @Nullable
-            @Override
-            public RpcResult<T> apply(@Nullable final Pair<RpcResult<T>, RpcResult<Void>> input) {
-                final RpcResultBuilder<T> resultBld;
-                if (input.getLeft().isSuccessful() && input.getRight().isSuccessful()) {
-                    resultBld = RpcResultBuilder.success();
-                } else {
-                    resultBld = RpcResultBuilder.failed();
-                }
+        return input -> {
+            final RpcResultBuilder<T> resultBld;
+            if (input.getLeft().isSuccessful() && input.getRight().isSuccessful()) {
+                resultBld = RpcResultBuilder.success();
+            } else {
+                resultBld = RpcResultBuilder.failed();
+            }
 
-                final ArrayList<RpcError> rpcErrors = new ArrayList<>(input.getLeft().getErrors());
-                rpcErrors.addAll(input.getRight().getErrors());
-                resultBld.withRpcErrors(rpcErrors);
+            final ArrayList<RpcError> rpcErrors = new ArrayList<>(input.getLeft().getErrors());
+            rpcErrors.addAll(input.getRight().getErrors());
+            resultBld.withRpcErrors(rpcErrors);
 
-                resultBld.withResult(input.getLeft().getResult());
+            resultBld.withResult(input.getLeft().getResult());
 
-                return resultBld.build();
-            }
+            return resultBld.build();
         };
     }
 
@@ -238,43 +217,39 @@ public final class GroupUtil {
         }
 
         public Function<List<RpcResult<O>>, RpcResult<List<BatchFailedGroupsOutput>>> invoke() {
-            return new Function<List<RpcResult<O>>, RpcResult<List<BatchFailedGroupsOutput>>>() {
-                @Nullable
-                @Override
-                public RpcResult<List<BatchFailedGroupsOutput>> apply(@Nullable final List<RpcResult<O>> innerInput) {
-                    final int sizeOfFutures = innerInput.size();
-                    Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
-                            "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
+            return innerInput -> {
+                final int sizeOfFutures = innerInput.size();
+                Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
+                        "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
 
-                    final List<BatchFailedGroupsOutput> batchGroups = new ArrayList<>();
-                    final Iterator<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group>
-                            batchGroupIterator = inputBatchGroups.iterator();
+                final List<BatchFailedGroupsOutput> batchGroups = new ArrayList<>();
+                final Iterator<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group>
+                        batchGroupIterator = inputBatchGroups.iterator();
 
-                    Collection<RpcError> groupErrors = new ArrayList<>(sizeOfFutures);
+                Collection<RpcError> groupErrors = new ArrayList<>(sizeOfFutures);
 
-                    int batchOrder = 0;
-                    for (RpcResult<O> groupModOutput : innerInput) {
-                        final GroupId groupId = batchGroupIterator.next().getGroupId();
+                int batchOrder = 0;
+                for (RpcResult<O> groupModOutput : innerInput) {
+                    final GroupId groupId = batchGroupIterator.next().getGroupId();
 
-                        if (!groupModOutput.isSuccessful()) {
-                            batchGroups.add(new BatchFailedGroupsOutputBuilder()
-                                    .setGroupId(groupId)
-                                    .setBatchOrder(batchOrder)
-                                    .build());
-                            groupErrors.addAll(groupModOutput.getErrors());
-                        }
-                        batchOrder++;
+                    if (!groupModOutput.isSuccessful()) {
+                        batchGroups.add(new BatchFailedGroupsOutputBuilder()
+                                .setGroupId(groupId)
+                                .setBatchOrder(batchOrder)
+                                .build());
+                        groupErrors.addAll(groupModOutput.getErrors());
                     }
+                    batchOrder++;
+                }
 
-                    final RpcResultBuilder<List<BatchFailedGroupsOutput>> resultBuilder;
-                    if (!groupErrors.isEmpty()) {
-                        resultBuilder = RpcResultBuilder.<List<BatchFailedGroupsOutput>>failed()
-                                .withRpcErrors(groupErrors).withResult(batchGroups);
-                    } else {
-                        resultBuilder = SUCCESSFUL_GROUP_OUTPUT_RPC_RESULT;
-                    }
-                    return resultBuilder.build();
+                final RpcResultBuilder<List<BatchFailedGroupsOutput>> resultBuilder;
+                if (!groupErrors.isEmpty()) {
+                    resultBuilder = RpcResultBuilder.<List<BatchFailedGroupsOutput>>failed()
+                            .withRpcErrors(groupErrors).withResult(batchGroups);
+                } else {
+                    resultBuilder = SUCCESSFUL_GROUP_OUTPUT_RPC_RESULT;
                 }
+                return resultBuilder.build();
             };
         }
     }
index a7d12aeb8fa59870477e4f2d47da45aef5de5512..1172cc47c6f4a883e0fbdf93dc404e3e0dfd4e94 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import javax.annotation.Nullable;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
@@ -49,19 +48,13 @@ public final class MeterUtil {
             RpcResultBuilder.success(Collections.<BatchFailedMetersOutput>emptyList());
 
     public static final Function<RpcResult<List<BatchFailedMetersOutput>>, RpcResult<AddMetersBatchOutput>>
-        METER_ADD_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedMetersOutput>>, RpcResult<AddMetersBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<AddMetersBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedMetersOutput>> batchMetersCumulatedResult) {
-                final AddMetersBatchOutput batchOutput = new AddMetersBatchOutputBuilder()
-                        .setBatchFailedMetersOutput(batchMetersCumulatedResult.getResult()).build();
+        METER_ADD_TRANSFORM = batchMetersCumulatedResult -> {
+            final AddMetersBatchOutput batchOutput = new AddMetersBatchOutputBuilder()
+                    .setBatchFailedMetersOutput(batchMetersCumulatedResult.getResult()).build();
 
-                final RpcResultBuilder<AddMetersBatchOutput> resultBld =
-                        createCumulativeRpcResult(batchMetersCumulatedResult, batchOutput);
-                return resultBld.build();
-            }
+            final RpcResultBuilder<AddMetersBatchOutput> resultBld =
+                    createCumulativeRpcResult(batchMetersCumulatedResult, batchOutput);
+            return resultBld.build();
         };
     public static final Function<Pair<RpcResult<AddMetersBatchOutput>,
                                       RpcResult<Void>>,
@@ -70,19 +63,14 @@ public final class MeterUtil {
 
     public static final Function<RpcResult<List<BatchFailedMetersOutput>>, RpcResult<RemoveMetersBatchOutput>>
         METER_REMOVE_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedMetersOutput>>, RpcResult<RemoveMetersBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<RemoveMetersBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedMetersOutput>> batchMetersCumulatedResult) {
+            batchMetersCumulatedResult -> {
                 final RemoveMetersBatchOutput batchOutput = new RemoveMetersBatchOutputBuilder()
                         .setBatchFailedMetersOutput(batchMetersCumulatedResult.getResult()).build();
 
                 final RpcResultBuilder<RemoveMetersBatchOutput> resultBld =
                         createCumulativeRpcResult(batchMetersCumulatedResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
     public static final Function<Pair<RpcResult<RemoveMetersBatchOutput>,
                                       RpcResult<Void>>,
                                       RpcResult<RemoveMetersBatchOutput>>
@@ -90,19 +78,14 @@ public final class MeterUtil {
 
     public static final Function<RpcResult<List<BatchFailedMetersOutput>>, RpcResult<UpdateMetersBatchOutput>>
         METER_UPDATE_TRANSFORM =
-        new Function<RpcResult<List<BatchFailedMetersOutput>>, RpcResult<UpdateMetersBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<UpdateMetersBatchOutput> apply(
-                    @Nullable final RpcResult<List<BatchFailedMetersOutput>> batchMetersCumulatedResult) {
+            batchMetersCumulatedResult -> {
                 final UpdateMetersBatchOutput batchOutput = new UpdateMetersBatchOutputBuilder()
                         .setBatchFailedMetersOutput(batchMetersCumulatedResult.getResult()).build();
 
                 final RpcResultBuilder<UpdateMetersBatchOutput> resultBld =
                         createCumulativeRpcResult(batchMetersCumulatedResult, batchOutput);
                 return resultBld.build();
-            }
-        };
+            };
     public static final Function<Pair<RpcResult<UpdateMetersBatchOutput>,
                                       RpcResult<Void>>,
                                       RpcResult<UpdateMetersBatchOutput>>
@@ -151,25 +134,21 @@ public final class MeterUtil {
     @VisibleForTesting
     static <T extends BatchMeterOutputListGrouping>
         Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>> createComposingFunction() {
-        return new Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>>() {
-            @Nullable
-            @Override
-            public RpcResult<T> apply(@Nullable final Pair<RpcResult<T>, RpcResult<Void>> input) {
-                final RpcResultBuilder<T> resultBld;
-                if (input.getLeft().isSuccessful() && input.getRight().isSuccessful()) {
-                    resultBld = RpcResultBuilder.success();
-                } else {
-                    resultBld = RpcResultBuilder.failed();
-                }
+        return input -> {
+            final RpcResultBuilder<T> resultBld;
+            if (input.getLeft().isSuccessful() && input.getRight().isSuccessful()) {
+                resultBld = RpcResultBuilder.success();
+            } else {
+                resultBld = RpcResultBuilder.failed();
+            }
 
-                final ArrayList<RpcError> rpcErrors = new ArrayList<>(input.getLeft().getErrors());
-                rpcErrors.addAll(input.getRight().getErrors());
-                resultBld.withRpcErrors(rpcErrors);
+            final ArrayList<RpcError> rpcErrors = new ArrayList<>(input.getLeft().getErrors());
+            rpcErrors.addAll(input.getRight().getErrors());
+            resultBld.withRpcErrors(rpcErrors);
 
-                resultBld.withResult(input.getLeft().getResult());
+            resultBld.withResult(input.getLeft().getResult());
 
-                return resultBld.build();
-            }
+            return resultBld.build();
         };
     }
 
@@ -208,43 +187,39 @@ public final class MeterUtil {
         }
 
         public Function<List<RpcResult<O>>, RpcResult<List<BatchFailedMetersOutput>>> invoke() {
-            return new Function<List<RpcResult<O>>, RpcResult<List<BatchFailedMetersOutput>>>() {
-                @Nullable
-                @Override
-                public RpcResult<List<BatchFailedMetersOutput>> apply(@Nullable final List<RpcResult<O>> innerInput) {
-                    final int sizeOfFutures = innerInput.size();
-                    Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
-                            "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
-
-                    final List<BatchFailedMetersOutput> batchMeters = new ArrayList<>();
-                    final Iterator<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter>
-                            batchMeterIterator = inputBatchMeters.iterator();
-
-                    Collection<RpcError> meterErrors = new ArrayList<>(sizeOfFutures);
-
-                    int batchOrder = 0;
-                    for (RpcResult<O> meterModOutput : innerInput) {
-                        final MeterId meterId = batchMeterIterator.next().getMeterId();
-
-                        if (!meterModOutput.isSuccessful()) {
-                            batchMeters.add(new BatchFailedMetersOutputBuilder()
-                                    .setBatchOrder(batchOrder)
-                                    .setMeterId(meterId)
-                                    .build());
-                            meterErrors.addAll(meterModOutput.getErrors());
-                        }
-                        batchOrder++;
+            return innerInput -> {
+                final int sizeOfFutures = innerInput.size();
+                Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
+                        "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
+
+                final List<BatchFailedMetersOutput> batchMeters = new ArrayList<>();
+                final Iterator<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter>
+                        batchMeterIterator = inputBatchMeters.iterator();
+
+                Collection<RpcError> meterErrors = new ArrayList<>(sizeOfFutures);
+
+                int batchOrder = 0;
+                for (RpcResult<O> meterModOutput : innerInput) {
+                    final MeterId meterId = batchMeterIterator.next().getMeterId();
+
+                    if (!meterModOutput.isSuccessful()) {
+                        batchMeters.add(new BatchFailedMetersOutputBuilder()
+                                .setBatchOrder(batchOrder)
+                                .setMeterId(meterId)
+                                .build());
+                        meterErrors.addAll(meterModOutput.getErrors());
                     }
+                    batchOrder++;
+                }
 
-                    final RpcResultBuilder<List<BatchFailedMetersOutput>> resultBuilder;
-                    if (!meterErrors.isEmpty()) {
-                        resultBuilder = RpcResultBuilder.<List<BatchFailedMetersOutput>>failed()
-                                .withRpcErrors(meterErrors).withResult(batchMeters);
-                    } else {
-                        resultBuilder = SUCCESSFUL_METER_OUTPUT_RPC_RESULT;
-                    }
-                    return resultBuilder.build();
+                final RpcResultBuilder<List<BatchFailedMetersOutput>> resultBuilder;
+                if (!meterErrors.isEmpty()) {
+                    resultBuilder = RpcResultBuilder.<List<BatchFailedMetersOutput>>failed()
+                            .withRpcErrors(meterErrors).withResult(batchMeters);
+                } else {
+                    resultBuilder = SUCCESSFUL_METER_OUTPUT_RPC_RESULT;
                 }
+                return resultBuilder.build();
             };
         }
     }
index cf8ad0ce610fcc7a4d82636a63953ed7808a9f53..f9f25d98b9261446ebe1429cb7208857894f2615 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 /**
@@ -69,9 +70,10 @@ public final class NodeConnectorRefToPortTranslator {
 
         Long port = null;
 
-        if (nodeConnectorRef.getValue() instanceof KeyedInstanceIdentifier) {
+        final InstanceIdentifier<?> value = nodeConnectorRef.getValue();
+        if (value instanceof KeyedInstanceIdentifier) {
             KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> identifier =
-                    (KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey>) nodeConnectorRef.getValue();
+                    (KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey>) value;
 
             OpenflowVersion ofVersion = OpenflowVersion.get(version);
             String nodeConnectorId = identifier.getKey().getId().getValue();