2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.neeo.internal.models;
15 import java.util.Arrays;
16 import java.util.Objects;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * The model representing Neeo Devices (serialize/deserialize json use only).
24 * @author Tim Roberts - Initial contribution
27 public class NeeoDevices {
30 private final NeeoDevice @Nullable [] devices;
33 * Instantiates a new neeo devices.
35 * @param devices the devices
37 NeeoDevices(NeeoDevice[] devices) {
38 Objects.requireNonNull(devices, "devices cannot be null");
39 this.devices = devices;
47 public NeeoDevice[] getDevices() {
48 final NeeoDevice[] localDevices = devices;
49 return localDevices == null ? new NeeoDevice[0] : localDevices;
59 public NeeoDevice getDevice(String key) {
60 for (NeeoDevice device : getDevices()) {
61 if (key.equalsIgnoreCase(device.getKey())) {
69 public String toString() {
70 return "NeeoDevice [devices=" + Arrays.toString(devices) + "]";