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;
*/
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");
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
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;
}
}
}
// 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);
comReference.get().send(cmd);
update();
}
-
- private static final Character[] LETTERS = new Character[] { 'A', 'B', 'C', 'D' };
}