2 * Copyright (c) 2010-2020 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.apache.commons.lang.StringUtils;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
23 * The model representing Neeo Scenarios (serialize/deserialize json use only).
25 * @author Tim Roberts - Initial contribution
28 public class NeeoScenarios {
31 private final NeeoScenario @Nullable [] scenarios;
34 * Instantiates a new neeo scenarios.
36 * @param scenarios the scenarios
38 NeeoScenarios(NeeoScenario[] scenarios) {
39 Objects.requireNonNull(scenarios, "scenarios cannot be null");
40 this.scenarios = scenarios;
46 * @return the scenarios
48 public NeeoScenario[] getScenarios() {
49 final NeeoScenario @Nullable [] localScenarios = scenarios;
50 return localScenarios == null ? new NeeoScenario[0] : localScenarios;
57 * @return the scenario
60 public NeeoScenario getScenario(String key) {
61 for (NeeoScenario scenario : getScenarios()) {
62 if (StringUtils.equalsIgnoreCase(key, scenario.getKey())) {
70 public String toString() {
71 return "NeeoScenarios [scenarios=" + Arrays.toString(scenarios) + "]";