[yamahareceiver] Remove Apache commons libraries (#12527)

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein 2022-03-27 08:53:21 -05:00 committed by GitHub
parent 80cb1ed251
commit c81506b44d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View 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' };
}