class DeviceLogic {

	public List<DeviceEntity> getDevices() {
		List<DeviceEntity> devicesList = new ArrayList<>();
		Device[] devices = this.spotifyAPICalls.getDevices();
		if (devices != null) {
			for (Device device : devices) {
				DeviceEntity deviceData;
				deviceData = new DeviceEntity(device.getType(), device.getName(), device.getId());
				if (this.deviceRegistry.findDeviceWithUri(device.getId()) != null) {
					deviceData = this.deviceRegistry.findDeviceWithUri(device.getId());
				} else {
					this.deviceRegistry.save(deviceData);
				}
				devicesList.add(deviceData);
			}
		}
		return devicesList;
	}

}