}
}
+ class DeviceNotFound extends DBusExecutionException {
+
+ public DeviceNotFound(final String message) {
+ super(message);
+ }
+ }
+
class GroupNotFound extends DBusExecutionException {
public GroupNotFound(final String message) {
@Override
public DBusPath getDevice(long deviceId) {
updateDevices();
- return new DBusPath(getDeviceObjectPath(objectPath, deviceId));
+ final var deviceOptional = devices.stream().filter(g -> g.getId().equals(deviceId)).findFirst();
+ if (deviceOptional.isEmpty()) {
+ throw new Error.DeviceNotFound("Device not found");
+ }
+ return deviceOptional.get().getObjectPath();
}
@Override