Merge "Apply some Objects.requireNonNull() modernization"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / GroupDescriptionService.java
index 2e6ca05a69debca42c280f22f6c1f7710ae119de..bd95ee2ddbe37e808e1ddfdc5f302a1f9e589faa 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -14,8 +14,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.services.ServiceException;
+import org.opendaylight.openflowplugin.impl.services.util.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
@@ -36,17 +35,23 @@ 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.MultipartRequestGroupDescCaseBuilder;
 
 final class GroupDescriptionService
-        extends AbstractCompatibleStatService<GetGroupDescriptionInput, GetGroupDescriptionOutput, GroupDescStatsUpdated> {
-    private static final MultipartRequestGroupDescCase GROUP_DESC_CASE = new MultipartRequestGroupDescCaseBuilder().build();
+        extends AbstractCompatibleStatService<GetGroupDescriptionInput,
+                                              GetGroupDescriptionOutput,
+                                              GroupDescStatsUpdated> {
+    private static final MultipartRequestGroupDescCase GROUP_DESC_CASE =
+            new MultipartRequestGroupDescCaseBuilder().build();
     private final ConvertorExecutor convertorExecutor;
 
-    public GroupDescriptionService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
+    GroupDescriptionService(RequestContextStack requestContextStack,
+                            DeviceContext deviceContext,
+                            AtomicLong compatibilityXidSeed,
+                            ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
         this.convertorExecutor = convertorExecutor;
     }
 
     @Override
-    protected OfHeader buildRequest(final Xid xid, final GetGroupDescriptionInput input) throws ServiceException {
+    protected OfHeader buildRequest(final Xid xid, final GetGroupDescriptionInput input) {
         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                 MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
         mprInput.setMultipartRequestBody(GROUP_DESC_CASE);
@@ -65,7 +70,7 @@ final class GroupDescriptionService
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
-        notification.setGroupDescStats(new ArrayList<GroupDescStats>());
+        notification.setGroupDescStats(new ArrayList<>());
         final VersionConvertorData data = new VersionConvertorData(getVersion());
 
         for (MultipartReply mpReply : result) {
@@ -74,9 +79,7 @@ final class GroupDescriptionService
             final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(
                     replyBody.getGroupDesc(), data);
 
-            if (groupDescStatsList.isPresent()) {
-                notification.getGroupDescStats().addAll(groupDescStatsList.get());
-            }
+            groupDescStatsList.ifPresent(groupDescStats -> notification.getGroupDescStats().addAll(groupDescStats));
         }
 
         return notification.build();