]> git.basschouten.com Git - openhab-addons.git/blob
0658093c5560993f9fc0d8919bce3dcfb9c942c8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.epsonprojector.internal;
14
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;
21
22 /**
23  * Represents all valid command types which could be processed by this
24  * binding.
25  *
26  * @author Pauli Anttila - Initial contribution
27  */
28 @NonNullByDefault
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);
58
59     private final String text;
60     private Class<? extends Item> itemClass;
61
62     private EpsonProjectorCommandType(final String text, Class<? extends Item> itemClass) {
63         this.text = text;
64         this.itemClass = itemClass;
65     }
66
67     @Override
68     public String toString() {
69         return text;
70     }
71
72     public Class<? extends Item> getItemClass() {
73         return itemClass;
74     }
75
76     /**
77      * Procedure to convert command type string to command type class.
78      *
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.
84      */
85     public static EpsonProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
86         for (EpsonProjectorCommandType c : EpsonProjectorCommandType.values()) {
87             if (c.text.equals(commandTypeText)) {
88                 return c;
89             }
90         }
91
92         throw new IllegalArgumentException("Not valid command type: " + commandTypeText);
93     }
94 }