*/
package org.openhab.binding.epsonprojector.internal;
-import java.io.InvalidClassException;
-
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.items.Item;
import org.openhab.core.library.items.DimmerItem;
*/
@NonNullByDefault
public enum EpsonProjectorCommandType {
- POWER("Power", SwitchItem.class),
- POWER_STATE("PowerState", StringItem.class),
- LAMP_TIME("LampTime", NumberItem.class),
- KEY_CODE("KeyCode", StringItem.class),
- VKEYSTONE("VerticalKeystone", NumberItem.class),
- HKEYSTONE("HorizontalKeystone", NumberItem.class),
- AKEYSTONE("AutoKeystone", SwitchItem.class),
- FREEZE("Freeze", SwitchItem.class),
- ASPECT_RATIO("AspectRatio", StringItem.class),
- LUMINANCE("Luminance", StringItem.class),
- SOURCE("Source", StringItem.class),
- BRIGHTNESS("Brightness", NumberItem.class),
- CONTRAST("Contrast", NumberItem.class),
- DENSITY("Density", NumberItem.class),
- TINT("Tint", NumberItem.class),
- COLOR_TEMP("ColorTemperature", NumberItem.class),
- FLESH_TEMP("FleshTemperature", NumberItem.class),
- COLOR_MODE("ColorMode", StringItem.class),
- HPOSITION("HorizontalPosition", NumberItem.class),
- VPOSITION("VerticalPosition", NumberItem.class),
- GAMMA("Gamma", StringItem.class),
- VOLUME("Volume", DimmerItem.class),
- MUTE("Mute", SwitchItem.class),
- HREVERSE("HorizontalReverse", SwitchItem.class),
- VREVERSE("VerticalReverse", SwitchItem.class),
- BACKGROUND("Background", StringItem.class),
- ERR_CODE("ErrCode", NumberItem.class),
- ERR_MESSAGE("ErrMessage", StringItem.class),;
+ POWER("power", SwitchItem.class),
+ POWER_STATE("powerstate", StringItem.class),
+ LAMP_TIME("lamptime", NumberItem.class),
+ KEY_CODE("keycode", StringItem.class),
+ VKEYSTONE("verticalkeystone", NumberItem.class),
+ HKEYSTONE("horizontalkeystone", NumberItem.class),
+ AKEYSTONE("autokeystone", SwitchItem.class),
+ FREEZE("freeze", SwitchItem.class),
+ ASPECT_RATIO("aspectratio", StringItem.class),
+ LUMINANCE("luminance", StringItem.class),
+ SOURCE("source", StringItem.class),
+ BRIGHTNESS("brightness", NumberItem.class),
+ CONTRAST("contrast", NumberItem.class),
+ DENSITY("density", NumberItem.class),
+ TINT("tint", NumberItem.class),
+ COLOR_TEMP("colortemperature", NumberItem.class),
+ FLESH_TEMP("fleshtemperature", NumberItem.class),
+ COLOR_MODE("colormode", StringItem.class),
+ HPOSITION("horizontalposition", NumberItem.class),
+ VPOSITION("verticalposition", NumberItem.class),
+ GAMMA("gamma", StringItem.class),
+ VOLUME("volume", DimmerItem.class),
+ MUTE("mute", SwitchItem.class),
+ HREVERSE("horizontalreverse", SwitchItem.class),
+ VREVERSE("verticalreverse", SwitchItem.class),
+ BACKGROUND("background", StringItem.class),
+ ERR_CODE("errcode", NumberItem.class),
+ ERR_MESSAGE("errmessage", StringItem.class),;
private final String text;
private Class<? extends Item> itemClass;
return itemClass;
}
- /**
- * Procedure to validate command type string.
- *
- * @param commandTypeText
- * command string e.g. RawData, Command, Brightness
- * @return true if item is valid.
- * @throws IllegalArgumentException
- * Not valid command type.
- * @throws InvalidClassException
- * Not valid class for command type.
- */
- public static boolean validateBinding(String commandTypeText, Class<? extends Item> itemClass)
- throws IllegalArgumentException, InvalidClassException {
- for (EpsonProjectorCommandType c : EpsonProjectorCommandType.values()) {
- if (c.text.equalsIgnoreCase(commandTypeText)) {
- if (c.getItemClass().equals(itemClass)) {
- return true;
- } else {
- throw new InvalidClassException("Not valid class for command type");
- }
- }
- }
-
- throw new IllegalArgumentException("Not valid command type");
- }
-
/**
* Procedure to convert command type string to command type class.
*
* @param commandTypeText
* command string e.g. RawData, Command, Brightness
* @return corresponding command type.
- * @throws InvalidClassException
- * Not valid class for command type.
+ * @throws IllegalArgumentException
+ * No valid class for command type.
*/
public static EpsonProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
for (EpsonProjectorCommandType c : EpsonProjectorCommandType.values()) {
- if (c.text.equalsIgnoreCase(commandTypeText)) {
+ if (c.text.equals(commandTypeText)) {
return c;
}
}
- throw new IllegalArgumentException("Not valid command type");
+ throw new IllegalArgumentException("Not valid command type: " + commandTypeText);
}
}