Bump MRI upstreams
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / multilayer / MultiLayerAggregateFlowMultipartService.java
index c2859606e4150afbc3f571ea42bb4068a4cde580..0f696787f7b0ce8f077a3a54a1ff2891975a8783 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.openflowplugin.impl.services.multilayer;
 
-import com.google.common.base.Function;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-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.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
 import org.opendaylight.openflowplugin.api.OFConstants;
@@ -26,7 +25,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.services.AbstractAggregateFlowMultipartService;
 import org.opendaylight.openflowplugin.impl.services.util.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
 import org.opendaylight.openflowplugin.impl.util.FlowCreatorUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
@@ -44,6 +42,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFlowMultipartService<MultipartReply> {
 
@@ -58,24 +58,23 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl
         super(requestContextStack, deviceContext);
         this.convertorExecutor = convertorExecutor;
         this.translatorLibrary = translatorLibrary;
-        this.data = new VersionConvertorData(getVersion());
+        data = new VersionConvertorData(getVersion());
     }
 
 
     @Override
     protected OfHeader buildRequest(final Xid xid,
-                                    final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) throws
-            ServiceException {
+                                    final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
         final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder
                 = new MultipartRequestAggregateCaseBuilder();
         final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
-        final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
+        final Uint8 tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
         mprAggregateRequestBuilder.setTableId(tableId);
         long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
-        mprAggregateRequestBuilder.setOutPort(outputPortValue);
+        mprAggregateRequestBuilder.setOutPort(Uint32.valueOf(outputPortValue));
 
-        final short version = getVersion();
-        if (version == OFConstants.OFP_VERSION_1_3) {
+        final Uint8 version = getVersion();
+        if (OFConstants.OFP_VERSION_1_3.equals(version)) {
 
             if (input.getCookie() == null) {
                 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
@@ -90,7 +89,7 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl
                 mprAggregateRequestBuilder.setCookieMask(
                         MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
             }
-            long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
+            Uint32 outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
             mprAggregateRequestBuilder.setOutGroup(outGroup);
         } else {
             mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
@@ -119,13 +118,11 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl
     public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> handleAndReply(
             final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
         return Futures.transform(handleServiceCall(input),
-                     (Function<RpcResult<List<MultipartReply>>,
-                             RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>)
             result -> {
-                if (Preconditions.checkNotNull(result).isSuccessful()) {
+                if (requireNonNull(result).isSuccessful()) {
                     final MessageTranslator<MultipartReply, AggregatedFlowStatistics>
                              messageTranslator = translatorLibrary.lookupTranslator(
-                             new TranslatorKey(getVersion(),
+                                 new TranslatorKey(getVersion(),
                                                MultipartReplyAggregateCase.class.getName()));
 
                     return RpcResultBuilder.success(
@@ -137,8 +134,8 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl
                                                                                           multipartReply,
                                                                                           getDeviceInfo(),
                                                                                           null))
-                                                                          .collect(Collectors
-                                                                                           .toList())))
+                                                                          .collect(Collectors.toList()))
+                                     .build())
                              .build();
                 }