public boolean hasEmbeddedDevices() { return getEmbeddedDevices() != null && getEmbeddedDevices().length > 0; }
protected Collection<D> findEmbeddedDevices(D current) { Collection<D> devices = new HashSet<>(); if (!current.isRoot() && current.getIdentity().getUdn() != null) devices.add(current); if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(findEmbeddedDevices(embeddedDevice)); } } return devices; }
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) { if (!deviceModel.hasEmbeddedDevices()) return; Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList); for (Device device : deviceModel.getEmbeddedDevices()) { generateDevice(namespace, device, descriptor, deviceListElement, info); } }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet<>(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (getType() != null) { // Only validate the graph if we have a device type - that means we validate only if there // actually is a fully hydrated graph, not just a discovered device of which we haven't even // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device // type. Now that is a risky assumption... errors.addAll(getVersion().validate()); if(getIdentity() != null) { errors.addAll(getIdentity().validate()); } if (getDetails() != null) { errors.addAll(getDetails().validate()); } if (hasServices()) { for (Service service : getServices()) { if (service != null) errors.addAll(service.validate()); } } if (hasEmbeddedDevices()) { for (Device embeddedDevice : getEmbeddedDevices()) { if (embeddedDevice != null) errors.addAll(embeddedDevice.validate()); } } } return errors; }
protected D find(UDN udn, D current) { if (current.getIdentity() != null && current.getIdentity().getUdn() != null) { if (current.getIdentity().getUdn().equals(udn)) return current; } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { D match; if ((match = find(udn, embeddedDevice)) != null) return match; } } return null; }
public boolean hasEmbeddedDevices() { return getEmbeddedDevices() != null && getEmbeddedDevices().length > 0; }
protected Collection<D> findEmbeddedDevices(D current) { Collection<D> devices = new HashSet(); if (!current.isRoot()) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(findEmbeddedDevices(embeddedDevice)); } } return devices; }
for (Device embedded : device.getEmbeddedDevices()) { createNodes(deviceNode, namespace, embedded);
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) { if (!deviceModel.hasEmbeddedDevices()) return; Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList); for (Device device : deviceModel.getEmbeddedDevices()) { generateDevice(namespace, device, descriptor, deviceListElement, info); } }
protected D find(UDN udn, D current) { if (current.getIdentity().getUdn().equals(udn)) return current; if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { D match; if ((match = find(udn, embeddedDevice)) != null) return match; } } return null; }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList(); if (getType() != null) { // Only validate the graph if we have a device type - that means we validate only if there // actually is a fully hydrated graph, not just a discovered device of which we haven't even // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device // type. Now that is a risky assumption... errors.addAll(getVersion().validate()); if (getDetails() != null) { errors.addAll(getDetails().validate()); } if (hasServices()) { for (Service service : getServices()) { if (service != null) errors.addAll(service.validate()); } } if (hasEmbeddedDevices()) { for (Device embeddedDevice : getEmbeddedDevices()) { if (embeddedDevice != null) errors.addAll(embeddedDevice.validate()); } } } return errors; }
public boolean hasEmbeddedDevices() { return getEmbeddedDevices() != null && getEmbeddedDevices().length > 0; }
protected Collection<D> findEmbeddedDevices(D current) { Collection<D> devices = new HashSet<>(); if (!current.isRoot() && current.getIdentity().getUdn() != null) devices.add(current); if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(findEmbeddedDevices(embeddedDevice)); } } return devices; }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet<>(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) { if (!deviceModel.hasEmbeddedDevices()) return; Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList); for (Device device : deviceModel.getEmbeddedDevices()) { generateDevice(namespace, device, descriptor, deviceListElement, info); } }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (getType() != null) { // Only validate the graph if we have a device type - that means we validate only if there // actually is a fully hydrated graph, not just a discovered device of which we haven't even // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device // type. Now that is a risky assumption... errors.addAll(getVersion().validate()); if(getIdentity() != null) { errors.addAll(getIdentity().validate()); } if (getDetails() != null) { errors.addAll(getDetails().validate()); } if (hasServices()) { for (Service service : getServices()) { if (service != null) errors.addAll(service.validate()); } } if (hasEmbeddedDevices()) { for (Device embeddedDevice : getEmbeddedDevices()) { if (embeddedDevice != null) errors.addAll(embeddedDevice.validate()); } } } return errors; }
protected D find(UDN udn, D current) { if (current.getIdentity() != null && current.getIdentity().getUdn() != null) { if (current.getIdentity().getUdn().equals(udn)) return current; } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { D match; if ((match = find(udn, embeddedDevice)) != null) return match; } } return null; }