]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix equalsIgnoreCase issue (#11140)
authormlobstein <michael.lobstein@gmail.com>
Tue, 24 Aug 2021 17:05:32 +0000 (12:05 -0500)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 17:05:32 +0000 (19:05 +0200)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
bundles/org.openhab.binding.benqprojector/README.md
bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/BenqProjectorCommandType.java
bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/handler/BenqProjectorHandler.java

index c306fb5dff73f2e9649b360a03fa4a36801aa7c8..9bae5644e6eee698c2b746b082b07e56f8412017 100644 (file)
@@ -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"]
index f1a67f4152899152cc0b982f4ee5bc11954e8ad8..28f349a71f3cba66d8d732a3a5ae8bf9bf0eeab2 100644 (file)
@@ -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);
     }
 }
index 63fb9c3c0b897b9607576ff328d1333756c85035..68529b5ac57c4bafbd8998ee397252af9a9f276a 100644 (file)
@@ -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());
         }
     }