Migrate Optional.get() callers
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / openroadminterfaces / OpenRoadmInterfacesImpl121.java
index 220209449b4382098255f46b830e1c6372857a49..a4512d8a5c9f8a9e92d681beade782ffa2e13a96 100755 (executable)
@@ -52,7 +52,7 @@ public class OpenRoadmInterfacesImpl121 {
         try {
             Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
             if (deviceTxOpt.isPresent()) {
-                deviceTx = deviceTxOpt.get();
+                deviceTx = deviceTxOpt.orElseThrow();
             } else {
                 throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
                     nodeId));
@@ -123,7 +123,7 @@ public class OpenRoadmInterfacesImpl121 {
                 interfaceName, nodeId), e);
         }
         if (intf2DeleteOpt.isPresent()) {
-            Interface intf2Delete = intf2DeleteOpt.get();
+            Interface intf2Delete = intf2DeleteOpt.orElseThrow();
             // State admin state to out of service
             InterfaceBuilder ifBuilder = new InterfaceBuilder()
                 .setAdministrativeState(AdminStates.OutOfService)
@@ -147,7 +147,7 @@ public class OpenRoadmInterfacesImpl121 {
             try {
                 Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
                 if (deviceTxOpt.isPresent()) {
-                    deviceTx = deviceTxOpt.get();
+                    deviceTx = deviceTxOpt.orElseThrow();
                 } else {
                     throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
                         nodeId));
@@ -191,7 +191,7 @@ public class OpenRoadmInterfacesImpl121 {
             Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         CircuitPacks cp = null;
         if (cpOpt.isPresent()) {
-            cp = cpOpt.get();
+            cp = cpOpt.orElseThrow();
         } else {
             throw new OpenRoadmInterfaceException(String.format(
                 "Could not find CircuitPack %s in equipment config datastore for node %s", circuitPackName, nodeId));
@@ -215,7 +215,7 @@ public class OpenRoadmInterfacesImpl121 {
             try {
                 Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
                 if (deviceTxOpt.isPresent()) {
-                    deviceTx = deviceTxOpt.get();
+                    deviceTx = deviceTxOpt.orElseThrow();
                 } else {
                     throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
                         nodeId));
@@ -242,7 +242,7 @@ public class OpenRoadmInterfacesImpl121 {
         try {
             supInterfOpt = getInterface(nodeId, interf);
             if (supInterfOpt.isPresent()) {
-                return supInterfOpt.get().getSupportingInterface();
+                return supInterfOpt.orElseThrow().getSupportingInterface();
             } else {
                 return null;
             }
@@ -259,7 +259,7 @@ public class OpenRoadmInterfacesImpl121 {
             .child(Ports.class, new PortsKey(ifBuilder.getSupportingPort()))
             .build();
         Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
-            portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+            portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
         if (port.getInterfaces() == null) {
             return false;
         }