2 * Copyright (c) 2010-2021 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.apache.commons.lang.StringUtils;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.openhab.io.neeo.internal.NeeoUtil;
21 * Represents a directory list item. This class is simply used for serialization of the result back to the brain.
23 * @author Tim Roberts - Initial Contribution
27 public class NeeoDirectoryResultItem {
28 /** The title (label) of the item */
29 private final String title;
31 /** The URI to the thumbnail representing the item */
33 private final String thumbnailUri;
35 /** The browse identifier (reflected back in a request if this item is a container) */
37 private final String browseIdentifier;
39 /** The action identifier (reflected back in a request if this is a leaf) */
41 private final String actionIdentifier;
43 /** Whether the item is queueable (no explanation posted by NEEO) */
44 private final boolean isQueueable;
47 * Creates the directory from the given items
49 * @param title a non-null, non-empty title
50 * @param thumbnailUri a possibly null, possibly empty thumbnail URI
51 * @param browseIdentifier a possibly null, possibly empty browse identifier
52 * @param actionIdentifier a possibly null, possibly empty action identifier
53 * @param isQueueable true/false if queueable
54 * @throws IllegalArgumentException if both browseIdentifier and actionIdentifier are null or empty
56 public NeeoDirectoryResultItem(String title, @Nullable String thumbnailUri, @Nullable String browseIdentifier,
57 @Nullable String actionIdentifier, boolean isQueueable) {
58 NeeoUtil.requireNotEmpty(title, "title cannot be empty");
60 if (StringUtils.isEmpty(browseIdentifier) && StringUtils.isEmpty(actionIdentifier)) {
61 throw new IllegalArgumentException("Either browserIdentifier or actionIdentifier must be specified");
65 this.thumbnailUri = thumbnailUri;
66 this.browseIdentifier = browseIdentifier;
67 this.actionIdentifier = actionIdentifier;
68 this.isQueueable = isQueueable;
72 * The title (label) of the item
74 * @return the non-null, non-empty title
76 public String getTitle() {
81 * The thumbnail URI representing the item
83 * @return a possibly null, possibly empty thumbnail URI
86 public String getThumbnailUri() {
91 * The browse identifier
93 * @return a possibly null, possibly empty browse identifier
96 public String getBrowseIdentifier() {
97 return browseIdentifier;
101 * The action identifier
103 * @return a possibly null, possibly empty action identifier
106 public String getActionIdentifier() {
107 return actionIdentifier;
111 * Whether the item is queueable or not
113 * @return true if queueable, false otherwise
115 public boolean isQueueable() {
120 public String toString() {
121 return "NeeoDiscoveryListResultItem [title=" + title + ", thumbnailUri=" + thumbnailUri + ", browseIdentifier="
122 + browseIdentifier + ", actionIdentifier=" + actionIdentifier + ", isQueueable=" + isQueueable + "]";