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.benqprojector.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.items.Item;
17 import org.openhab.core.library.items.NumberItem;
18 import org.openhab.core.library.items.StringItem;
19 import org.openhab.core.library.items.SwitchItem;
22 * Represents all valid command types which could be processed by this
25 * @author Michael Lobstein - Initial contribution
28 public enum BenqProjectorCommandType {
29 POWER("power", SwitchItem.class),
30 SOURCE("source", StringItem.class),
31 PICTURE_MODE("picturemode", StringItem.class),
32 ASPECT_RATIO("aspectratio", StringItem.class),
33 FREEZE("freeze", SwitchItem.class),
34 BLANK("blank", SwitchItem.class),
35 DIRECTCMD("directcmd", StringItem.class),
36 LAMP_TIME("lamptime", NumberItem.class);
38 private final String text;
39 private Class<? extends Item> itemClass;
41 private BenqProjectorCommandType(final String text, Class<? extends Item> itemClass) {
43 this.itemClass = itemClass;
47 public String toString() {
51 public Class<? extends Item> getItemClass() {
56 * Procedure to convert command type string to command type class.
58 * @param commandTypeText
59 * command string e.g. RawData, Command, Brightness
60 * @return corresponding command type.
61 * @throws IllegalArgumentException
62 * No valid class for command type.
64 public static BenqProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
65 for (BenqProjectorCommandType c : BenqProjectorCommandType.values()) {
66 if (c.text.equals(commandTypeText)) {
71 throw new IllegalArgumentException("Not valid command type: " + commandTypeText);