@Override public boolean is(Port port) { return port != null && port.type() == Port.Type.OMS && super.is(port); }
@Override public boolean is(Port port) { return port != null && port.type() == Port.Type.ODUCLT && super.is(port); }
@Override protected boolean isIncluded(Port port) { return OPTICAL.contains(port.type()) && super.isIncluded(port); }
@Override public boolean is(Port port) { return port != null && port.type() == Port.Type.OTU && super.is(port); }
@Override public boolean is(Port port) { return port != null && port.type() == Port.Type.OCH && super.is(port); }
@Override public ObjectNode encode(Port port, CodecContext context) { checkNotNull(port, "Port cannot be null"); ObjectNode result = context.mapper().createObjectNode() .put(ELEMENT, port.element().id().toString()) .put(PORT_NAME, portName(port.number())) .put(IS_ENABLED, port.isEnabled()) .put(TYPE, port.type().toString().toLowerCase()) .put(PORT_SPEED, port.portSpeed()); return annotate(result, port, context); }
/** * Produces JSON array containing ports of the specified device. * * @param service device service * @param mapper object mapper * @param device infrastructure devices * @return JSON array */ public JsonNode jsonPorts(DeviceService service, ObjectMapper mapper, Device device) { ObjectNode result = mapper.createObjectNode(); ArrayNode ports = mapper.createArrayNode(); for (Port port : service.getPorts(device.id())) { if (isIncluded(port)) { ports.add(mapper.createObjectNode() .put("port", port.number().toString()) .put("isEnabled", port.isEnabled()) .put("type", port.type().toString().toLowerCase()) .put("portSpeed", port.portSpeed()) .set("annotations", annotations(mapper, port.annotations()))); } } result.set("device", jsonForEntity(device, Device.class)); result.set("ports", ports); return result; }
private DeviceEvent updatePort(Device device, Port oldPort, Port newPort, Map<PortNumber, Port> ports) { if (oldPort.isEnabled() != newPort.isEnabled() || oldPort.type() != newPort.type() || oldPort.portSpeed() != newPort.portSpeed() || !AnnotationsUtil.isEqual(oldPort.annotations(), newPort.annotations())) { ports.put(oldPort.number(), newPort); return new DeviceEvent(PORT_UPDATED, device, newPort); } return null; }
private void printPort(Port port) { String portName = portName(port.number()); Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled"; String portType = port.type().toString().toLowerCase(); String annotations = annotations(port.annotations()); print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); }
protected void printPorts(DeviceService service, Device device) { List<Port> ports = new ArrayList<>(service.getPorts(device.id())); Collections.sort(ports, Comparators.PORT_COMPARATOR); for (Port port : ports) { if (!isIncluded(port)) { continue; } String portName = port.number().toString(); Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled"; String portType = port.type().toString().toLowerCase(); String annotations = annotations(port.annotations()); print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); } } }