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.io.neeo.internal.models;
15 import java.util.Objects;
17 import org.apache.commons.lang.StringUtils;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.thing.type.ChannelKind;
22 * Enumeration of channel kinds (item or trigger)
24 * @author Tim Roberts - Initial Contribution
27 public enum NeeoDeviceChannelKind {
28 /** Represents an item */
30 /** Represents an trigger item */
33 /** The text value of the enum */
34 private final String text;
37 * Constructs the NeeoDeviceChannelKind using the specified text
39 * @param text the text
41 private NeeoDeviceChannelKind(final String text) {
42 Objects.requireNonNull(text, "text is required");
47 * Parses the text into a NeeoDeviceChannelKind enum (ignoring case)
49 * @param text the text to parse
50 * @return the NeeoDeviceChannelKind type
52 public static NeeoDeviceChannelKind parse(final String text) {
53 if (StringUtils.isEmpty(text)) {
56 for (NeeoDeviceChannelKind enm : NeeoDeviceChannelKind.values()) {
57 if (StringUtils.equalsIgnoreCase(text, enm.text)) {
66 * Returns the {@link NeeoDeviceChannelKind} for the given {@link ChannelKind}
68 * @param kind a non-null {@link ChannelKind}
69 * @return a non-null {@link NeeoDeviceChannelKind}
71 public static NeeoDeviceChannelKind get(ChannelKind kind) {
72 Objects.requireNonNull(kind, "kind cannot be null");
73 return kind == ChannelKind.TRIGGER ? TRIGGER : ITEM;
77 public String toString() {