2 * Copyright (c) 2010-2022 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.epsonprojector.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.items.Item;
17 import org.openhab.core.library.items.DimmerItem;
18 import org.openhab.core.library.items.NumberItem;
19 import org.openhab.core.library.items.StringItem;
20 import org.openhab.core.library.items.SwitchItem;
23 * Represents all valid command types which could be processed by this
26 * @author Pauli Anttila - Initial contribution
29 public enum EpsonProjectorCommandType {
30 POWER("power", SwitchItem.class),
31 POWER_STATE("powerstate", StringItem.class),
32 LAMP_TIME("lamptime", NumberItem.class),
33 KEY_CODE("keycode", StringItem.class),
34 VKEYSTONE("verticalkeystone", NumberItem.class),
35 HKEYSTONE("horizontalkeystone", NumberItem.class),
36 AKEYSTONE("autokeystone", SwitchItem.class),
37 FREEZE("freeze", SwitchItem.class),
38 ASPECT_RATIO("aspectratio", StringItem.class),
39 LUMINANCE("luminance", StringItem.class),
40 SOURCE("source", StringItem.class),
41 BRIGHTNESS("brightness", NumberItem.class),
42 CONTRAST("contrast", NumberItem.class),
43 DENSITY("density", NumberItem.class),
44 TINT("tint", NumberItem.class),
45 COLOR_TEMP("colortemperature", NumberItem.class),
46 FLESH_TEMP("fleshtemperature", NumberItem.class),
47 COLOR_MODE("colormode", StringItem.class),
48 HPOSITION("horizontalposition", NumberItem.class),
49 VPOSITION("verticalposition", NumberItem.class),
50 GAMMA("gamma", StringItem.class),
51 VOLUME("volume", DimmerItem.class),
52 MUTE("mute", SwitchItem.class),
53 HREVERSE("horizontalreverse", SwitchItem.class),
54 VREVERSE("verticalreverse", SwitchItem.class),
55 BACKGROUND("background", StringItem.class),
56 ERR_CODE("errcode", NumberItem.class),
57 ERR_MESSAGE("errmessage", StringItem.class);
59 private final String text;
60 private Class<? extends Item> itemClass;
62 private EpsonProjectorCommandType(final String text, Class<? extends Item> itemClass) {
64 this.itemClass = itemClass;
68 public String toString() {
72 public Class<? extends Item> getItemClass() {
77 * Procedure to convert command type string to command type class.
79 * @param commandTypeText
80 * command string e.g. RawData, Command, Brightness
81 * @return corresponding command type.
82 * @throws IllegalArgumentException
83 * No valid class for command type.
85 public static EpsonProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
86 for (EpsonProjectorCommandType c : EpsonProjectorCommandType.values()) {
87 if (c.text.equals(commandTypeText)) {
92 throw new IllegalArgumentException("Not valid command type: " + commandTypeText);