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;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
21 * The model representing Neeo Recipes (serialize/deserialize json use only).
23 * @author Tim Roberts - Initial contribution
26 public class NeeoRecipes {
29 private NeeoRecipe[] recipes;
32 * Creates the recipes from the given recipes
34 * @param recipes the recipes
36 NeeoRecipes(NeeoRecipe[] recipes) {
37 this.recipes = recipes;
45 public NeeoRecipe[] getRecipes() {
50 * Gets the recipe by key
53 * @return the recipe or null if none found
56 public NeeoRecipe getRecipe(String key) {
61 for (NeeoRecipe recipe : recipes) {
62 if (key.equalsIgnoreCase(recipe.getKey())) {
70 * Gets the recipe by a scenario key and recipe type
73 * @param type the recipe type
74 * @return the recipe or null if none found
77 public NeeoRecipe getRecipeByScenarioKey(String key, String type) {
82 for (NeeoRecipe recipe : recipes) {
83 if (key.equalsIgnoreCase(recipe.getScenarioKey()) && type.equalsIgnoreCase(recipe.getType())) {
91 * Gets the recipe by name
93 * @param name the recipe name
94 * @return the recipe or null if none found
97 public NeeoRecipe getRecipeByName(String name) {
102 for (NeeoRecipe recipe : recipes) {
103 if (name.equalsIgnoreCase(recipe.getName())) {
111 public String toString() {
112 return "NeeoRecipes [recipes=" + Arrays.toString(recipes) + "]";