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 Rooms (serialize/deserialize json use only).
24 * @author Tim Roberts - Initial contribution
27 public class NeeoRooms {
30 private final NeeoRoom @Nullable [] rooms;
33 * Instantiates a new neeo rooms.
35 * @param rooms the rooms
37 NeeoRooms(NeeoRoom[] rooms) {
38 Objects.requireNonNull(rooms, "rooms cannot be null");
47 public NeeoRoom[] getRooms() {
48 final NeeoRoom @Nullable [] localRooms = rooms;
49 return localRooms == null ? new NeeoRoom[0] : localRooms;
58 NeeoRoom getRoom(String key) {
59 for (NeeoRoom room : getRooms()) {
60 if (key.equalsIgnoreCase(room.getKey())) {
64 return new NeeoRoom();
68 public String toString() {
69 return "NeeoRooms [rooms=" + Arrays.toString(rooms) + "]";