]> git.basschouten.com Git - openhab-addons.git/commitdiff
[yamahareceiver] Remove Apache commons libraries (#12527)
authormlobstein <michael.lobstein@gmail.com>
Sun, 27 Mar 2022 13:53:21 +0000 (08:53 -0500)
committerGitHub <noreply@github.com>
Sun, 27 Mar 2022 13:53:21 +0000 (15:53 +0200)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputWithPresetControlXML.java

index 5a6868f0bf4770c4e663fb62260d709e8b2ebb21..609f80c3e70bf08b7497bdc7e6da69eb9f93bd3e 100644 (file)
@@ -18,8 +18,6 @@ import static org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLUtils.
 
 import java.io.IOException;
 
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
 import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPresetControl;
 import org.openhab.binding.yamahareceiver.internal.protocol.ReceivedMessageParseException;
@@ -50,6 +48,8 @@ import org.w3c.dom.Node;
  */
 public class InputWithPresetControlXML extends AbstractInputControlXML implements InputWithPresetControl {
 
+    private static final String PRESET_LETTERS = "ABCD";
+
     protected CommandTemplate preset = new CommandTemplate(
             "<Play_Control><Preset><Preset_Sel>%s</Preset_Sel></Preset></Play_Control>",
             "Play_Control/Preset/Preset_Sel");
@@ -147,7 +147,7 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
 
     private int convertToPresetNumber(String presetValue) {
         if (!presetValue.isEmpty()) {
-            if (StringUtils.isNumeric(presetValue)) {
+            if (presetValue.chars().allMatch(Character::isDigit)) {
                 return Integer.parseInt(presetValue);
             } else {
                 // special handling for RX-V3900, where 'A1' becomes 101 and 'B2' becomes 202 preset
@@ -156,7 +156,7 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
                     if (Character.isLetter(presetAlpha) && Character.isUpperCase(presetAlpha)
                             && Character.isDigit(presetValue.charAt(1))) {
                         int presetNumber = Integer.parseInt(presetValue.substring(1));
-                        return (ArrayUtils.indexOf(LETTERS, presetAlpha) + 1) * 100 + presetNumber;
+                        return (PRESET_LETTERS.indexOf(presetAlpha) + 1) * 100 + presetNumber;
                     }
                 }
             }
@@ -177,7 +177,7 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
         // special handling for RX-V3900, where 'A1' becomes 101 and 'B2' becomes 202 preset
         if (presetChannel > 100) {
             int presetNumber = presetChannel % 100;
-            char presetAlpha = LETTERS[presetChannel / 100 - 1];
+            char presetAlpha = PRESET_LETTERS.charAt(presetChannel / 100 - 1);
             presetValue = Character.toString(presetAlpha) + presetNumber;
         } else {
             presetValue = Integer.toString(presetChannel);
@@ -187,6 +187,4 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
         comReference.get().send(cmd);
         update();
     }
-
-    private static final Character[] LETTERS = new Character[] { 'A', 'B', 'C', 'D' };
 }