mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
Fix equalsIgnoreCase issue (#11140)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
5ce27e3407
commit
81989112d1
@ -70,10 +70,10 @@ Some notes:
|
||||
things/benq.things:
|
||||
|
||||
```
|
||||
//serial port connection
|
||||
// serial port connection
|
||||
benqprojector:projector-serial:hometheater "Projector" [ serialPort="COM5", pollingInterval=10 ]
|
||||
|
||||
// serial over IP connection
|
||||
// direct IP or serial over IP connection
|
||||
benqprojector:projector-tcp:hometheater "Projector" [ host="192.168.0.10", port=8000, pollingInterval=10 ]
|
||||
|
||||
```
|
||||
@ -94,7 +94,7 @@ Number benqLampTime "Lamp Time [%d h]" <switch> { channel="benqprojector:p
|
||||
sitemaps/benq.sitemap
|
||||
|
||||
```
|
||||
sitemap benq label="BenQ Projector Demo" {
|
||||
sitemap benq label="BenQ Projector" {
|
||||
Frame label="Controls" {
|
||||
Switch item=benqPower label="Power"
|
||||
Selection item=benqSource label="Source" mappings=["hdmi"="HDMI", "hdmi2"="HDMI2", "ypbr"="Component", "RGB"="Computer", "vid"="Video", "svid"="S-Video"]
|
||||
|
@ -12,8 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.benqprojector.internal;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.items.Item;
|
||||
import org.openhab.core.library.items.NumberItem;
|
||||
@ -28,14 +26,14 @@ import org.openhab.core.library.items.SwitchItem;
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum BenqProjectorCommandType {
|
||||
POWER("Power", SwitchItem.class),
|
||||
SOURCE("Source", StringItem.class),
|
||||
PICTURE_MODE("PictureMode", StringItem.class),
|
||||
ASPECT_RATIO("AspectRatio", StringItem.class),
|
||||
FREEZE("Freeze", SwitchItem.class),
|
||||
BLANK("Blank", SwitchItem.class),
|
||||
DIRECTCMD("DirectCmd", StringItem.class),
|
||||
LAMP_TIME("LampTime", NumberItem.class);
|
||||
POWER("power", SwitchItem.class),
|
||||
SOURCE("source", StringItem.class),
|
||||
PICTURE_MODE("picturemode", StringItem.class),
|
||||
ASPECT_RATIO("aspectratio", StringItem.class),
|
||||
FREEZE("freeze", SwitchItem.class),
|
||||
BLANK("blank", SwitchItem.class),
|
||||
DIRECTCMD("directcmd", StringItem.class),
|
||||
LAMP_TIME("lamptime", NumberItem.class);
|
||||
|
||||
private final String text;
|
||||
private Class<? extends Item> itemClass;
|
||||
@ -54,48 +52,22 @@ public enum BenqProjectorCommandType {
|
||||
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 (BenqProjectorCommandType c : BenqProjectorCommandType.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 BenqProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
|
||||
for (BenqProjectorCommandType c : BenqProjectorCommandType.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);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class BenqProjectorHandler extends BaseThingHandler {
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warn("Unknown channel {}", channel.getUID().getId());
|
||||
logger.warn("Unknown channel {}, exception: {}", channel.getUID().getId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user