try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
Optional<Mapping> mapObject = readTx.read(LogicalDatastoreType.CONFIGURATION, portMappingIID).get();
if (mapObject.isPresent()) {
- Mapping mapping = mapObject.get();
+ Mapping mapping = mapObject.orElseThrow();
LOG.info("Found mapping for {} - {}. Mapping: {}", nodeId, logicalConnPoint, mapping.toString());
return mapping;
}
LOG.warn("Could not get portMapping for node {}", nodeId);
return null;
}
- Map<MappingKey, Mapping> mappings = portMapppingOpt.get().getMapping();
+ Map<MappingKey, Mapping> mappings = portMapppingOpt.orElseThrow().getMapping();
for (Mapping mapping : mappings.values()) {
if (circuitPackName.equals(mapping.getSupportingCircuitPackName())
&& portName.equals(mapping.getSupportingPort())) {
Optional<McCapabilities> mcCapObject = readTx.read(LogicalDatastoreType.CONFIGURATION,
mcCapabilitiesIID).get();
if (mcCapObject.isPresent()) {
- McCapabilities mcCap = mcCapObject.get();
+ McCapabilities mcCap = mcCapObject.orElseThrow();
LOG.info("Found MC-cap for {} - {}. Mapping: {}", nodeId, mcLcp, mcCap.toString());
return mcCap;
}
Optional<Nodes> nodePortMapObject =
readTx.read(LogicalDatastoreType.CONFIGURATION, nodePortMappingIID).get();
if (nodePortMapObject.isPresent()) {
- Nodes node = nodePortMapObject.get();
+ Nodes node = nodePortMapObject.orElseThrow();
LOG.info("Found node {} in portmapping.", nodeId);
return node;
}
LOG.warn("Could not get portMapping for node {}", nodeId);
return null;
}
- Map<MappingKey, Mapping> mappings = nodePortmapppingOpt.get().getMapping();
+ Map<MappingKey, Mapping> mappings = nodePortmapppingOpt.orElseThrow().getMapping();
for (Mapping mapping : mappings.values()) {
if (interfName.equals(mapping.getSupportingOts())) {
return mapping;