Use Optional.isEmpty()
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / BrokerFacade.java
index 0eba3a783a802cfd10d0b08c20e341b46c585e3a..3a4c0ec1cf310555d8c64df1fad14f9574d2f46a 100644 (file)
@@ -548,8 +548,8 @@ public class BrokerFacade implements Closeable {
 
         try {
             final Optional<NormalizedNode<?, ?>> optional = transaction.read(datastore, path).get();
-            return !optional.isPresent() ? null : withDefa == null ? optional.get() :
-                prepareDataByParamWithDef(optional.get(), path, withDefa);
+            return optional.map(normalizedNode -> withDefa == null ? normalizedNode :
+                prepareDataByParamWithDef(normalizedNode, path, withDefa)).orElse(null);
         } catch (InterruptedException e) {
             LOG.warn("Error reading {} from datastore {}", path, datastore.name(), e);
             throw new RestconfDocumentedException("Error reading data.", e);