Fix equalsIgnoreCase issue (#11140)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
@@ -70,10 +70,10 @@ Some notes:
|
|||||||
things/benq.things:
|
things/benq.things:
|
||||||
|
|
||||||
```
|
```
|
||||||
//serial port connection
|
// serial port connection
|
||||||
benqprojector:projector-serial:hometheater "Projector" [ serialPort="COM5", pollingInterval=10 ]
|
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 ]
|
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
|
sitemaps/benq.sitemap
|
||||||
|
|
||||||
```
|
```
|
||||||
sitemap benq label="BenQ Projector Demo" {
|
sitemap benq label="BenQ Projector" {
|
||||||
Frame label="Controls" {
|
Frame label="Controls" {
|
||||||
Switch item=benqPower label="Power"
|
Switch item=benqPower label="Power"
|
||||||
Selection item=benqSource label="Source" mappings=["hdmi"="HDMI", "hdmi2"="HDMI2", "ypbr"="Component", "RGB"="Computer", "vid"="Video", "svid"="S-Video"]
|
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;
|
package org.openhab.binding.benqprojector.internal;
|
||||||
|
|
||||||
import java.io.InvalidClassException;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.items.Item;
|
import org.openhab.core.items.Item;
|
||||||
import org.openhab.core.library.items.NumberItem;
|
import org.openhab.core.library.items.NumberItem;
|
||||||
@@ -28,14 +26,14 @@ import org.openhab.core.library.items.SwitchItem;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public enum BenqProjectorCommandType {
|
public enum BenqProjectorCommandType {
|
||||||
POWER("Power", SwitchItem.class),
|
POWER("power", SwitchItem.class),
|
||||||
SOURCE("Source", StringItem.class),
|
SOURCE("source", StringItem.class),
|
||||||
PICTURE_MODE("PictureMode", StringItem.class),
|
PICTURE_MODE("picturemode", StringItem.class),
|
||||||
ASPECT_RATIO("AspectRatio", StringItem.class),
|
ASPECT_RATIO("aspectratio", StringItem.class),
|
||||||
FREEZE("Freeze", SwitchItem.class),
|
FREEZE("freeze", SwitchItem.class),
|
||||||
BLANK("Blank", SwitchItem.class),
|
BLANK("blank", SwitchItem.class),
|
||||||
DIRECTCMD("DirectCmd", StringItem.class),
|
DIRECTCMD("directcmd", StringItem.class),
|
||||||
LAMP_TIME("LampTime", NumberItem.class);
|
LAMP_TIME("lamptime", NumberItem.class);
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
private Class<? extends Item> itemClass;
|
private Class<? extends Item> itemClass;
|
||||||
@@ -54,48 +52,22 @@ public enum BenqProjectorCommandType {
|
|||||||
return 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 (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.
|
* Procedure to convert command type string to command type class.
|
||||||
*
|
*
|
||||||
* @param commandTypeText
|
* @param commandTypeText
|
||||||
* command string e.g. RawData, Command, Brightness
|
* command string e.g. RawData, Command, Brightness
|
||||||
* @return corresponding command type.
|
* @return corresponding command type.
|
||||||
* @throws InvalidClassException
|
* @throws IllegalArgumentException
|
||||||
* Not valid class for command type.
|
* No valid class for command type.
|
||||||
*/
|
*/
|
||||||
public static BenqProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
|
public static BenqProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
|
||||||
for (BenqProjectorCommandType c : BenqProjectorCommandType.values()) {
|
for (BenqProjectorCommandType c : BenqProjectorCommandType.values()) {
|
||||||
if (c.text.equalsIgnoreCase(commandTypeText)) {
|
if (c.text.equals(commandTypeText)) {
|
||||||
return c;
|
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) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.warn("Unknown channel {}", channel.getUID().getId());
|
logger.warn("Unknown channel {}, exception: {}", channel.getUID().getId(), e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user