Unwrap Optionals 39/77939/1
authorStephen Kitt <skitt@redhat.com>
Mon, 19 Nov 2018 12:10:41 +0000 (13:10 +0100)
committerStephen Kitt <skitt@redhat.com>
Mon, 19 Nov 2018 12:10:41 +0000 (13:10 +0100)
This patch fixes a few instances of left-over code which used to
transform a Guava Optional to a Java Optional, but is no longer
necessary since the callee returns a Java Optional directly.

Change-Id: I631c34d645a1d5c8a5b599d4eeb7f161812f40fd
Signed-off-by: Stephen Kitt <skitt@redhat.com>
applications/device-ownership-service/src/main/java/org/opendaylight/openflowplugin/applications/deviceownershipservice/impl/DeviceOwnershipServiceImpl.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java

index e58c91134f7e2fbbaecdc8f6e7777c371c7df9c1..ec397ea82cb2c713b244a99ee5116417aed60580 100644 (file)
@@ -48,7 +48,7 @@ public class DeviceOwnershipServiceImpl implements DeviceOwnershipService, Entit
         EntityOwnershipState state = ownershipStateCache.get(nodeId);
         if (state == null) {
             LOG.debug("The ownership state for node {} is not cached. Retrieving from the EOS Datastore");
-            java.util.Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(nodeId);
+            Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(nodeId);
             if (status.isPresent()) {
                 state = status.get();
                 ownershipStateCache.put(nodeId, state);
@@ -78,14 +78,13 @@ public class DeviceOwnershipServiceImpl implements DeviceOwnershipService, Entit
         }
     }
 
-    private java.util.Optional<EntityOwnershipState> getCurrentOwnershipStatus(final String nodeId) {
+    private Optional<EntityOwnershipState> getCurrentOwnershipStatus(final String nodeId) {
         org.opendaylight.mdsal.eos.binding.api.Entity entity = createNodeEntity(nodeId);
         Optional<EntityOwnershipState> ownershipStatus = eos.getOwnershipState(entity);
         if (ownershipStatus.isPresent()) {
             LOG.trace("Fetched ownership status for node {} is {}", nodeId, ownershipStatus.get());
-            return java.util.Optional.of(ownershipStatus.get());
         }
-        return java.util.Optional.empty();
+        return ownershipStatus;
     }
 
     private org.opendaylight.mdsal.eos.binding.api.Entity createNodeEntity(final String nodeId) {
index 485926a9da2144ba44a34b261e404ec8caebdc74..c5f985e2458e4fea2c08410f466aea8afd042992 100644 (file)
@@ -199,7 +199,7 @@ public final class LLDPDiscoveryUtils {
         Preconditions.checkNotNull(eos, "Entity ownership service must not be null");
 
         EntityOwnershipState state = null;
-        java.util.Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(eos, nodeId);
+        Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(eos, nodeId);
         if (status.isPresent()) {
             state = status.get();
         } else {
@@ -208,16 +208,15 @@ public final class LLDPDiscoveryUtils {
         return state != null && state.equals(EntityOwnershipState.IS_OWNER);
     }
 
-    private static java.util.Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos,
+    private static Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos,
             final String nodeId) {
         Entity entity = createNodeEntity(nodeId);
         Optional<EntityOwnershipState> ownershipStatus = eos.getOwnershipState(entity);
 
         if (ownershipStatus.isPresent()) {
             LOG.debug("Fetched ownership status for node {} is {}", nodeId, ownershipStatus.get());
-            return java.util.Optional.of(ownershipStatus.get());
         }
-        return java.util.Optional.empty();
+        return ownershipStatus;
     }
 
     private static Entity createNodeEntity(final String nodeId) {