@RequestMapping("/device_status") public @ResponseBody DeviceStatus[] getDeviceStatus() { Device devices[] = powerControlDeviceService.getDevices(); DeviceStatus[] deviceStatus = new DeviceStatus[devices.length]; for (int i = 0; i < devices.length; i++) { deviceStatus[i] = new DeviceStatus(devices[i]); } return deviceStatus; }
@RequestMapping("/device_status/{id}") public @ResponseBody DeviceStatus getDeviceStatus(@PathVariable("id") long id) { Device devices[] = powerControlDeviceService.getDevices(); for (int i = 0; i < devices.length; i++) { if (devices[i].getId() == id) { return new DeviceStatus(devices[i]); } } return null; }