public class PortMappingVersion121 {
private static final Logger LOG = LoggerFactory.getLogger(PortMappingVersion121.class);
+ private static final Map<Direction, String> SUFFIX;
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
private final OpenRoadmInterfaces openRoadmInterfaces;
+ static {
+ SUFFIX = Map.of(
+ Direction.Tx, "TX",
+ Direction.Rx, "RX",
+ Direction.Bidirectional, "TXRX");
+ }
+
public PortMappingVersion121(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
OpenRoadmInterfaces openRoadmInterfaces) {
this.dataBroker = dataBroker;
}
private String createLogicalConnectionPort(Ports port, int index, int portIndex) {
- String lcp = null;
- switch (port.getPortDirection()) {
- case Tx:
- lcp = "SRG" + index + "-PP" + portIndex + "-TX";
- break;
- case Rx:
- lcp = "SRG" + index + "-PP" + portIndex + "-RX";
- break;
- case Bidirectional:
- lcp = "SRG" + index + "-PP" + portIndex + "-TXRX";
- break;
- default:
- LOG.error("Unsupported port direction for port {} : {}", port, port.getPortDirection());
+ if (SUFFIX.containsKey(port.getPortDirection())) {
+ return String.join("-", "SRG" + index, "PP" + portIndex, SUFFIX.get(port.getPortDirection()));
}
- return lcp;
+ LOG.error("port {} : Unsupported port direction {}", port, port.getPortDirection());
+ return null;
}
private Map<Integer, Degree> getDegreesMap(String deviceId, Info ordmInfo) {
// some mutualization would be helpful
public class PortMappingVersion221 {
private static final Logger LOG = LoggerFactory.getLogger(PortMappingVersion221.class);
+ private static final Map<Direction, String> SUFFIX;
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
private final OpenRoadmInterfaces openRoadmInterfaces;
+ static {
+ SUFFIX = Map.of(
+ Direction.Tx, "TX",
+ Direction.Rx, "RX",
+ Direction.Bidirectional, "TXRX");
+ }
+
public PortMappingVersion221(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
OpenRoadmInterfaces openRoadmInterfaces) {
this.dataBroker = dataBroker;
}
private String createLogicalConnectionPort(Ports port, int index, int portIndex) {
- String lcp = null;
- switch (port.getPortDirection()) {
- case Tx:
- lcp = "SRG" + index + "-PP" + portIndex + "-TX";
- break;
- case Rx:
- lcp = "SRG" + index + "-PP" + portIndex + "-RX";
- break;
- case Bidirectional:
- lcp = "SRG" + index + "-PP" + portIndex + "-TXRX";
- break;
- default:
- LOG.error("Unsupported port direction for port {} : {}", port, port.getPortDirection());
+ if (SUFFIX.containsKey(port.getPortDirection())) {
+ return String.join("-", "SRG" + index, "PP" + portIndex, SUFFIX.get(port.getPortDirection()));
}
- return lcp;
+ LOG.error("port {} : Unsupported port direction {}", port, port.getPortDirection());
+ return null;
}
private Map<Integer, Degree> getDegreesMap(String deviceId, Info ordmInfo) {
// some mutualization would be helpful
public class PortMappingVersion710 {
private static final Logger LOG = LoggerFactory.getLogger(PortMappingVersion710.class);
+ private static final Map<Direction, String> SUFFIX;
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
private final OpenRoadmInterfaces openRoadmInterfaces;
+ static {
+ SUFFIX = Map.of(
+ Direction.Tx, "TX",
+ Direction.Rx, "RX",
+ Direction.Bidirectional, "TXRX");
+ }
+
public PortMappingVersion710(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
OpenRoadmInterfaces openRoadmInterfaces) {
this.dataBroker = dataBroker;
}
private String createLogicalConnectionPort(Ports port, int index, int portIndex) {
- String lcp = null;
- switch (port.getPortDirection()) {
- case Tx:
- lcp = "SRG" + index + "-PP" + portIndex + "-TX";
- break;
- case Rx:
- lcp = "SRG" + index + "-PP" + portIndex + "-RX";
- break;
- case Bidirectional:
- lcp = "SRG" + index + "-PP" + portIndex + "-TXRX";
- break;
- default:
- LOG.error("Unsupported port direction for port {} : {}", port, port.getPortDirection());
+ if (SUFFIX.containsKey(port.getPortDirection())) {
+ return String.join("-", "SRG" + index, "PP" + portIndex, SUFFIX.get(port.getPortDirection()));
}
- return lcp;
+ LOG.error("port {} : Unsupported port direction {}", port, port.getPortDirection());
+ return null;
}
private Map<McCapabilityProfileKey, McCapabilityProfile> getMcCapabilityProfiles(String deviceId, Info ordmInfo) {