Simplify AbstractNeutronInterface::readMd
authorStephen Kitt <skitt@redhat.com>
Thu, 26 Nov 2015 08:44:25 +0000 (09:44 +0100)
committerStephen Kitt <skitt@redhat.com>
Thu, 26 Nov 2015 08:44:25 +0000 (09:44 +0100)
Use B for the parameter type to avoid masking the main T parameter
type.

Inline the optional handling.

Change-Id: I3f54589aec36b7fb378d7a0936743961946aa11b
Signed-off-by: Stephen Kitt <skitt@redhat.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/crud/impl/AbstractNeutronInterface.java

index 178a228f7aa3c7c82e07d7e6ab520fedb1b5d8aa..841e6bf7360d44e8a11a45eeec723ea920a26513 100644 (file)
@@ -55,17 +55,13 @@ public abstract class AbstractNeutronInterface<T extends DataObject, S extends I
 
     protected abstract T toMd(String uuid);
 
-    protected <T extends org.opendaylight.yangtools.yang.binding.DataObject> T readMd(InstanceIdentifier<T> path) {
-        T result = null;
+    protected <B extends org.opendaylight.yangtools.yang.binding.DataObject> B readMd(InstanceIdentifier<B> path) {
+        B result = null;
         final ReadOnlyTransaction transaction = getDataBroker().newReadOnlyTransaction();
-        CheckedFuture<Optional<T>, ReadFailedException> future = transaction.read(LogicalDatastoreType.CONFIGURATION, path);
+        CheckedFuture<Optional<B>, ReadFailedException> future = transaction.read(LogicalDatastoreType.CONFIGURATION, path);
         if (future != null) {
-            Optional<T> optional;
             try {
-                optional = future.checkedGet();
-                if (optional.isPresent()) {
-                    result = optional.get();
-                }
+                result = future.checkedGet().orNull();
             } catch (ReadFailedException e) {
                 LOGGER.warn("Failed to read {}", path, e);
             }