mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[max] Remove org.apache.commons (#14413)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
parent
c544f12b82
commit
c9864d6aa2
@ -21,11 +21,11 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.max.internal.Utils;
|
||||
import org.openhab.binding.max.internal.device.Device;
|
||||
import org.openhab.binding.max.internal.device.RoomInformation;
|
||||
import org.openhab.core.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -16,7 +16,6 @@ import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.max.internal.Utils;
|
||||
|
||||
@ -49,9 +48,13 @@ public class TCommand extends CubeCommand {
|
||||
@Override
|
||||
public String getCommandString() {
|
||||
final int updateForced = forceUpdate ? FORCE_UPDATE : NO_FORCE_UPDATE;
|
||||
byte[] commandArray = null;
|
||||
byte[] commandArray = new byte[0];
|
||||
for (String rfAddress : rfAddresses) {
|
||||
commandArray = ArrayUtils.addAll(Utils.hexStringToByteArray(rfAddress), commandArray);
|
||||
byte[] rfAddressArray = Utils.hexStringToByteArray(rfAddress);
|
||||
byte[] tnmpArray = new byte[rfAddressArray.length + commandArray.length];
|
||||
System.arraycopy(rfAddressArray, 0, tnmpArray, 0, rfAddressArray.length);
|
||||
System.arraycopy(commandArray, 0, tnmpArray, rfAddressArray.length, commandArray.length);
|
||||
commandArray = tnmpArray;
|
||||
}
|
||||
String encodedString = Base64.getEncoder().encodeToString(commandArray);
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class MaxCubeBridgeHandler extends BaseBridgeHandler {
|
||||
/** maximum queue size that we're allowing */
|
||||
private static final int MAX_COMMANDS = 50;
|
||||
private static final int MAX_DUTY_CYCLE = 80;
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmm");
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd-HHmm");
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MaxCubeBridgeHandler.class);
|
||||
private final List<Device> devices = new ArrayList<>();
|
||||
@ -1025,7 +1025,7 @@ public class MaxCubeBridgeHandler extends BaseBridgeHandler {
|
||||
public void backup() {
|
||||
this.backup = BackupState.REQUESTED;
|
||||
this.backupUtil = new MaxBackupUtils(
|
||||
new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter));
|
||||
new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().format(FORMATTER));
|
||||
socketClose();
|
||||
}
|
||||
}
|
||||
|
@ -536,30 +536,30 @@ public class MaxDevicesHandler extends BaseThingHandler implements DeviceStatusL
|
||||
*/
|
||||
private void setDeviceConfiguration(Device device) {
|
||||
try {
|
||||
boolean config_changed = false;
|
||||
boolean configChanged = false;
|
||||
logger.debug("MAX! {} {} configuration update", device.getType(), device.getSerialNumber());
|
||||
Configuration configuration = editConfiguration();
|
||||
if (!device.getRoomName().equalsIgnoreCase((String) getConfig().get(PROPERTY_ROOMNAME))) {
|
||||
configuration.put(PROPERTY_ROOMNAME, device.getRoomName());
|
||||
config_changed = true;
|
||||
configChanged = true;
|
||||
}
|
||||
if (getConfig().get(PROPERTY_ROOMID) == null || new BigDecimal(device.getRoomId())
|
||||
.compareTo((BigDecimal) getConfig().get(PROPERTY_ROOMID)) != 0) {
|
||||
configuration.put(PROPERTY_ROOMID, new BigDecimal(device.getRoomId()));
|
||||
config_changed = true;
|
||||
configChanged = true;
|
||||
}
|
||||
if (!device.getName().equalsIgnoreCase((String) getConfig().get(PROPERTY_DEVICENAME))) {
|
||||
configuration.put(PROPERTY_DEVICENAME, device.getName());
|
||||
config_changed = true;
|
||||
configChanged = true;
|
||||
}
|
||||
if (!device.getRFAddress().equalsIgnoreCase((String) getConfig().get(PROPERTY_RFADDRESS))) {
|
||||
configuration.put(PROPERTY_RFADDRESS, device.getRFAddress());
|
||||
config_changed = true;
|
||||
configChanged = true;
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : device.getProperties().entrySet()) {
|
||||
configuration.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (config_changed) {
|
||||
if (configChanged) {
|
||||
updateConfiguration(configuration);
|
||||
logger.debug("Config updated: {}", configuration.getProperties());
|
||||
} else {
|
||||
|
@ -25,10 +25,10 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.max.internal.Utils;
|
||||
import org.openhab.binding.max.internal.device.DeviceType;
|
||||
import org.openhab.core.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -109,11 +109,7 @@ public final class CMessage extends Message {
|
||||
|
||||
private String getSerialNumber(byte[] bytes) {
|
||||
byte[] sn = new byte[10];
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sn[i] = bytes[i + 8];
|
||||
}
|
||||
|
||||
System.arraycopy(bytes, 8, sn, 0, sn.length);
|
||||
return new String(sn, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@ -124,10 +120,8 @@ public final class CMessage extends Message {
|
||||
try {
|
||||
int dataStart = 18;
|
||||
byte[] sn = new byte[bytes.length - dataStart];
|
||||
System.arraycopy(bytes, dataStart, sn, 0, sn.length);
|
||||
|
||||
for (int i = 0; i < sn.length; i++) {
|
||||
sn[i] = bytes[i + dataStart];
|
||||
}
|
||||
logger.trace("DataBytes: {}", Utils.getHex(sn));
|
||||
return new String(sn, StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
@ -278,7 +272,7 @@ public final class CMessage extends Message {
|
||||
logger.debug("RoomID: {}", roomId);
|
||||
for (String key : properties.keySet()) {
|
||||
if (!key.startsWith("Unknown")) {
|
||||
String propertyName = String.join(" ", StringUtils.splitByCharacterTypeCamelCase(key));
|
||||
String propertyName = String.join(" ", StringUtils.splitByCharacterType(key));
|
||||
logger.debug("{}: {}", propertyName, properties.get(key));
|
||||
} else {
|
||||
logger.debug("{}: {}", key, properties.get(key));
|
||||
|
@ -91,15 +91,15 @@ public class MessageProcessorTest {
|
||||
|
||||
@Test
|
||||
public void testMultilineM_Message() throws Exception {
|
||||
String line1_part1 = "M:00,02,";
|
||||
String line1_part2 = "VgIMAQpXb2huemltbWVyCvMrAgtUb2lsZXR0ZSBFRwrenQMOVG9pbGV0dGUgMS4gT0cK3rgECkJhZGV6aW1tZXIK3qoFDFNjaGxhZnppbW1lcgresQYDSmFuD4lCBwlDaHJpc3RpbmEPiTYIBEZsdXIPiT0KEEJhZGV6aW1tZXIgMi4gT0cPiRwLBULDvHJvD4k/DAxHw6RzdGV6aW1tZXIPiRoJC1dhc2Noa8O8Y2hlD4lXNgQHOCtLRVEwMTg4NjczCFRlcnJhc3NlAQQHMblLRVEwMTg3MTkwCEZsdXJ0w7xyAQIK8ytLRVEwMzc5NTg3C1dhbmRoZWl6dW5nAQIK9P9LRVEwMzgwMDU1DkZlbnN0ZXJoZWl6dW5nAQQHMbtLRVEwMTg3MTg4CEZsdXJ0w7xyAgQHMuxLRVEwMTg2ODg0B0ZlbnN0ZXICAQrenUtFUTA0MDY5NjIHSGVpenVuZwIBCt64S0VRMDQwNjk4OQdIZWl6dW5nAwQIFGdLRVEwMTkwNTc3B0ZlbnN0ZXIDBAc2l0tFUTAxODU5NDUIRmx1cnTDvHIEAQreqktFUTA0MDY5NzUHSGVpenVuZwQBCt8JS0VRMDQwNzA3MA5IYW5kdHVjaGVpenVuZwQEBzhT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TA5ODI2NzcOV2FuZHRoZXJtb3N0YXQGAxBV40xFUTA5ODI2NzIOV2FuZHRoZXJtb3N0YXQKBAcxoEtFUTAxODcyMTYLV2FzY2hrw7xjaGUF";
|
||||
String line1 = line1Part1 + line1Part2;
|
||||
|
||||
String line2_part1 = "M:01,02,";
|
||||
String line2_part2 = "AxBV8ExFUTA5ODI2ODUOV2FuZHRoZXJtb3N0YXQJBA/v50xFUTA3OTQ0NzcNQmFsa29uZmVuc3RlcgkBD4lXTEVRMTAwNDYyMRZIZWl6dW5nIHVudGVybSBGZW5zdGVyCQQP8llMRVEwNzkzODUwDkZlbnN0ZXIgcmVjaHRzCQQP8bxMRVEwNzk0MDA3DUZlbnN0ZXIgbGlua3MJAQ+JOExFUTEwMDQ1OTAOSGVpenVuZyBCYWxrb24JBA/yLExFUTA3OTM4OTUKQmFsa29udMO8cgkED++zTEVRMDc5NDUyOQhGbHVydMO8cgkB";
|
||||
String line2 = line2_part1 + line2_part2;
|
||||
String line2Part1 = "M:01,02,";
|
||||
String line2Part2 = "AxBV8ExFUTA5ODI2ODUOV2FuZHRoZXJtb3N0YXQJBA/v50xFUTA3OTQ0NzcNQmFsa29uZmVuc3RlcgkBD4lXTEVRMTAwNDYyMRZIZWl6dW5nIHVudGVybSBGZW5zdGVyCQQP8llMRVEwNzkzODUwDkZlbnN0ZXIgcmVjaHRzCQQP8bxMRVEwNzk0MDA3DUZlbnN0ZXIgbGlua3MJAQ+JOExFUTEwMDQ1OTAOSGVpenVuZyBCYWxrb24JBA/yLExFUTA3OTM4OTUKQmFsa29udMO8cgkED++zTEVRMDc5NDUyOQhGbHVydMO8cgkB";
|
||||
String line2 = line2Part1 + line2Part2;
|
||||
|
||||
String expectedString = line1 + line2_part2;
|
||||
String expectedString = line1 + line2Part2;
|
||||
MMessage expectedMessage = new MMessage(expectedString);
|
||||
|
||||
assertFalse(this.processor.addReceivedLine(line1));
|
||||
|
Loading…
Reference in New Issue
Block a user