@Test public void testConfigAddStaticLambda() { OPC.portType(Port.Type.ODUCLT) .portNumberName(PORT_NUMBER) .staticLambda(CFG_STATIC_LAMBDA); PortDescription res; res = OpticalPortOperator.combine(OPC, N_DESC); assertEquals("Original port name expected", DESC_PORT_NAME, res.portNumber().name()); assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT)); long sl = Long.valueOf(res.annotations().value(AnnotationKeys.STATIC_LAMBDA)); assertEquals(CFG_STATIC_LAMBDA, sl); }
public static PortDescription combine(OpticalPortConfig opc, PortDescription descr) { if (opc == null) { return descr; } PortNumber port = descr.portNumber(); final String name = opc.name(); final String numName = opc.numberName(); PortNumber newPort = null; if (port == null) { if (!numName.isEmpty()) { final long pn = Long.parseLong(numName); newPort = (!name.isEmpty()) ? PortNumber.portNumber(pn, name) : PortNumber.portNumber(pn); } else { throw new RuntimeException("Possible misconfig, bailing on handling for: \n\t" + descr); } } else if ((!name.isEmpty()) && !name.equals(port.name())) { final long pn = (numName.isEmpty()) ? port.toLong() : Long.parseLong(numName); newPort = PortNumber.portNumber(pn, name); } boolean noOwrite = opc.type() == descr.type(); SparseAnnotations sa = combine(opc, descr.annotations()); if (noOwrite) { return updateDescription((newPort == null) ? port : newPort, sa, descr); } else { log.info("Type rewrite from {} to {} required", descr.type(), opc.type()); } return descr; }
OpticalPortOperator implements ConfigOperator { public static PortDescription combine(OpticalPortConfig opc, PortDescription descr) { if (opc == null) { return descr; } PortNumber port = descr.portNumber(); final String name = opc.name(); final String numName = opc.numberName(); PortNumber newPort = null; if (port == null) { if (!numName.isEmpty()) { final long pn = Long.parseLong(numName); newPort = (!name.isEmpty()) ? PortNumber.portNumber(pn, name) : PortNumber.portNumber(pn); } else { throw new RuntimeException("Possible misconfig, bailing on handling for: \n\t" + descr); } } else if ((!name.isEmpty()) && !name.equals(port.name())) { final long pn = (numName.isEmpty()) ? port.toLong() : Long.parseLong(numName); newPort = PortNumber.portNumber(pn, name); } boolean noOwrite = opc.type() == descr.type(); SparseAnnotations sa = combine(opc, descr.annotations()); if (noOwrite) { return updateDescription((newPort == null) ? port : newPort, sa, descr); } else { log.info("Type rewrite from {} to {} required", descr.type(), opc.type()); } return descr; } }
OpticalPortOperator implements ConfigOperator { public static PortDescription combine(OpticalPortConfig opc, PortDescription descr) { if (opc == null) { return descr; } PortNumber port = descr.portNumber(); final String name = opc.name(); final String numName = opc.numberName(); PortNumber newPort = null; if (port == null) { if (!numName.isEmpty()) { final long pn = Long.parseLong(numName); newPort = (!name.isEmpty()) ? PortNumber.portNumber(pn, name) : PortNumber.portNumber(pn); } else { throw new RuntimeException("Possible misconfig, bailing on handling for: \n\t" + descr); } } else if ((!name.isEmpty()) && !name.equals(port.name())) { final long pn = (numName.isEmpty()) ? port.toLong() : Long.parseLong(numName); newPort = PortNumber.portNumber(pn, name); } boolean noOwrite = opc.type() == descr.type(); SparseAnnotations sa = combine(opc, descr.annotations()); if (noOwrite) { return updateDescription((newPort == null) ? port : newPort, sa, descr); } else { log.info("Type rewrite from {} to {} required", descr.type(), opc.type()); } return descr; } private  OpticalPortOperator(); }
OpticalPortOperator implements ConfigOperator { public static PortDescription combine(OpticalPortConfig opc, PortDescription descr) { if (opc == null) { return descr; } PortNumber port = descr.portNumber(); final String name = opc.name(); final String numName = opc.numberName(); PortNumber newPort = null; if (port == null) { if (!numName.isEmpty()) { final long pn = Long.parseLong(numName); newPort = (!name.isEmpty()) ? PortNumber.portNumber(pn, name) : PortNumber.portNumber(pn); } else { throw new RuntimeException("Possible misconfig, bailing on handling for: \n\t" + descr); } } else if ((!name.isEmpty()) && !name.equals(port.name())) { final long pn = (numName.isEmpty()) ? port.toLong() : Long.parseLong(numName); newPort = PortNumber.portNumber(pn, name); } boolean noOwrite = opc.type() == descr.type(); SparseAnnotations sa = combine(opc, descr.annotations()); if (noOwrite) { return updateDescription((newPort == null) ? port : newPort, sa, descr); } else { log.info("Type rewrite from {} to {} required", descr.type(), opc.type()); } return descr; } private  OpticalPortOperator(); static PortDescription combine(OpticalPortConfig opc, PortDescription descr); static SparseAnnotations combine(OpticalPortConfig opc, SparseAnnotations an); static PortDescription descriptionOf(Port port); }
OpticalPortOperator implements ConfigOperator { public static PortDescription combine(OpticalPortConfig opc, PortDescription descr) { if (opc == null) { return descr; } PortNumber port = descr.portNumber(); final String name = opc.name(); final String numName = opc.numberName(); PortNumber newPort = null; if (port == null) { if (!numName.isEmpty()) { final long pn = Long.parseLong(numName); newPort = (!name.isEmpty()) ? PortNumber.portNumber(pn, name) : PortNumber.portNumber(pn); } else { throw new RuntimeException("Possible misconfig, bailing on handling for: \n\t" + descr); } } else if ((!name.isEmpty()) && !name.equals(port.name())) { final long pn = (numName.isEmpty()) ? port.toLong() : Long.parseLong(numName); newPort = PortNumber.portNumber(pn, name); } boolean noOwrite = opc.type() == descr.type(); SparseAnnotations sa = combine(opc, descr.annotations()); if (noOwrite) { return updateDescription((newPort == null) ? port : newPort, sa, descr); } else { log.info("Type rewrite from {} to {} required", descr.type(), opc.type()); } return descr; } private  OpticalPortOperator(); static PortDescription combine(OpticalPortConfig opc, PortDescription descr); static SparseAnnotations combine(OpticalPortConfig opc, SparseAnnotations an); static PortDescription descriptionOf(Port port);  }