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.io.neeo.internal.models;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.io.neeo.internal.NeeoUtil;
20 * Represents a directory list item. This class is simply used for serialization of the result back to the brain.
22 * @author Tim Roberts - Initial Contribution
26 public class NeeoDirectoryResultItem {
27 /** The title (label) of the item */
28 private final String title;
30 /** The URI to the thumbnail representing the item */
31 private final @Nullable String thumbnailUri;
33 /** The browse identifier (reflected back in a request if this item is a container) */
34 private final @Nullable String browseIdentifier;
36 /** The action identifier (reflected back in a request if this is a leaf) */
37 private final @Nullable String actionIdentifier;
39 /** Whether the item is queueable (no explanation posted by NEEO) */
40 private final boolean isQueueable;
43 * Creates the directory from the given items
45 * @param title a non-null, non-empty title
46 * @param thumbnailUri a possibly null, possibly empty thumbnail URI
47 * @param browseIdentifier a possibly null, possibly empty browse identifier
48 * @param actionIdentifier a possibly null, possibly empty action identifier
49 * @param isQueueable true/false if queueable
50 * @throws IllegalArgumentException if both browseIdentifier and actionIdentifier are null or empty
52 public NeeoDirectoryResultItem(String title, @Nullable String thumbnailUri, @Nullable String browseIdentifier,
53 @Nullable String actionIdentifier, boolean isQueueable) {
54 NeeoUtil.requireNotEmpty(title, "title cannot be empty");
56 if ((browseIdentifier == null || browseIdentifier.isEmpty())
57 && (actionIdentifier == null || actionIdentifier.isEmpty())) {
58 throw new IllegalArgumentException("Either browserIdentifier or actionIdentifier must be specified");
62 this.thumbnailUri = thumbnailUri;
63 this.browseIdentifier = browseIdentifier;
64 this.actionIdentifier = actionIdentifier;
65 this.isQueueable = isQueueable;
69 * The title (label) of the item
71 * @return the non-null, non-empty title
73 public String getTitle() {
78 * The thumbnail URI representing the item
80 * @return a possibly null, possibly empty thumbnail URI
83 public String getThumbnailUri() {
88 * The browse identifier
90 * @return a possibly null, possibly empty browse identifier
93 public String getBrowseIdentifier() {
94 return browseIdentifier;
98 * The action identifier
100 * @return a possibly null, possibly empty action identifier
103 public String getActionIdentifier() {
104 return actionIdentifier;
108 * Whether the item is queueable or not
110 * @return true if queueable, false otherwise
112 public boolean isQueueable() {
117 public String toString() {
118 return "NeeoDiscoveryListResultItem [title=" + title + ", thumbnailUri=" + thumbnailUri + ", browseIdentifier="
119 + browseIdentifier + ", actionIdentifier=" + actionIdentifier + ", isQueueable=" + isQueueable + "]";