@Test public void testDescOps() { DeviceDescription desc = BasicDeviceOperator.combine(null, DEV1); assertEquals(desc, DEV1); desc = BasicDeviceOperator.combine(SW_BDC, DEV1); assertEquals(NAME1, desc.annotations().value(AnnotationKeys.DRIVER)); desc = BasicDeviceOperator.combine(RD_BDC, DEV1); assertEquals("Wrong type", ROADM, desc.type()); assertEquals("Wrong manufacturer", MANUFACTURER, desc.manufacturer()); assertEquals("Wrong HwVersion", HW_VERSION, desc.hwVersion()); assertEquals("Wrong swVersion", SW_VERSION, desc.swVersion()); assertEquals("Wrong serial", SERIAL, desc.serialNumber()); assertEquals("Wrong management Address", MANAGEMENT_ADDRESS, desc.annotations().value(AnnotationKeys.MANAGEMENT_ADDRESS)); desc = BasicDeviceOperator.combine(OT_BDC, DEV1); assertEquals(OTN, desc.type()); }
public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { if (bdc == null || descr == null) { return descr; } Device.Type type = descr.type(); if (bdc.type() != null && bdc.type() != type) { type = bdc.type(); } String manufacturer = descr.manufacturer(); if (bdc.manufacturer() != null && !bdc.manufacturer().equals(manufacturer)) { manufacturer = bdc.manufacturer(); } String hwVersion = descr.hwVersion(); if (bdc.hwVersion() != null && !bdc.hwVersion().equals(hwVersion)) { hwVersion = bdc.hwVersion(); } String swVersion = descr.swVersion(); if (bdc.swVersion() != null && !bdc.swVersion().equals(swVersion)) { swVersion = bdc.swVersion(); } String serial = descr.serialNumber(); if (bdc.serial() != null && !bdc.serial().equals(serial)) { serial = bdc.serial(); } SparseAnnotations sa = combine(bdc, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), sa); }
BasicDeviceOperator implements ConfigOperator { public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { if (bdc == null || descr == null) { return descr; } Device.Type type = descr.type(); if (bdc.type() != null && bdc.type() != type) { type = bdc.type(); } String manufacturer = descr.manufacturer(); if (bdc.manufacturer() != null && !bdc.manufacturer().equals(manufacturer)) { manufacturer = bdc.manufacturer(); } String hwVersion = descr.hwVersion(); if (bdc.hwVersion() != null && !bdc.hwVersion().equals(hwVersion)) { hwVersion = bdc.hwVersion(); } String swVersion = descr.swVersion(); if (bdc.swVersion() != null && !bdc.swVersion().equals(swVersion)) { swVersion = bdc.swVersion(); } String serial = descr.serialNumber(); if (bdc.serial() != null && !bdc.serial().equals(serial)) { serial = bdc.serial(); } SparseAnnotations sa = combine(bdc, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), sa); } }
BasicDeviceOperator implements ConfigOperator { public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { if (bdc == null || descr == null) { return descr; } Device.Type type = descr.type(); if (bdc.type() != null && bdc.type() != type) { type = bdc.type(); } String manufacturer = descr.manufacturer(); if (bdc.manufacturer() != null && !bdc.manufacturer().equals(manufacturer)) { manufacturer = bdc.manufacturer(); } String hwVersion = descr.hwVersion(); if (bdc.hwVersion() != null && !bdc.hwVersion().equals(hwVersion)) { hwVersion = bdc.hwVersion(); } String swVersion = descr.swVersion(); if (bdc.swVersion() != null && !bdc.swVersion().equals(swVersion)) { swVersion = bdc.swVersion(); } String serial = descr.serialNumber(); if (bdc.serial() != null && !bdc.serial().equals(serial)) { serial = bdc.serial(); } SparseAnnotations sa = combine(bdc, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), sa); } private  BasicDeviceOperator(); }
BasicDeviceOperator implements ConfigOperator { public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { if (bdc == null || descr == null) { return descr; } Device.Type type = descr.type(); if (bdc.type() != null && bdc.type() != type) { type = bdc.type(); } String manufacturer = descr.manufacturer(); if (bdc.manufacturer() != null && !bdc.manufacturer().equals(manufacturer)) { manufacturer = bdc.manufacturer(); } String hwVersion = descr.hwVersion(); if (bdc.hwVersion() != null && !bdc.hwVersion().equals(hwVersion)) { hwVersion = bdc.hwVersion(); } String swVersion = descr.swVersion(); if (bdc.swVersion() != null && !bdc.swVersion().equals(swVersion)) { swVersion = bdc.swVersion(); } String serial = descr.serialNumber(); if (bdc.serial() != null && !bdc.serial().equals(serial)) { serial = bdc.serial(); } SparseAnnotations sa = combine(bdc, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), sa); } private  BasicDeviceOperator(); static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr); static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an); static DeviceDescription descriptionOf(Device device); }
BasicDeviceOperator implements ConfigOperator { public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { if (bdc == null || descr == null) { return descr; } Device.Type type = descr.type(); if (bdc.type() != null && bdc.type() != type) { type = bdc.type(); } String manufacturer = descr.manufacturer(); if (bdc.manufacturer() != null && !bdc.manufacturer().equals(manufacturer)) { manufacturer = bdc.manufacturer(); } String hwVersion = descr.hwVersion(); if (bdc.hwVersion() != null && !bdc.hwVersion().equals(hwVersion)) { hwVersion = bdc.hwVersion(); } String swVersion = descr.swVersion(); if (bdc.swVersion() != null && !bdc.swVersion().equals(swVersion)) { swVersion = bdc.swVersion(); } String serial = descr.serialNumber(); if (bdc.serial() != null && !bdc.serial().equals(serial)) { serial = bdc.serial(); } SparseAnnotations sa = combine(bdc, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), sa); } private  BasicDeviceOperator(); static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr); static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an); static DeviceDescription descriptionOf(Device device);  }