[imperihome] Remove org.apache.common (#14441)

Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2023-02-19 20:30:58 +01:00 committed by GitHub
parent f795abbce7
commit 9828dafdb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View File

@ -15,13 +15,13 @@ package org.openhab.io.imperihome.internal.model.device;
import java.math.BigDecimal;
import java.math.RoundingMode;
import org.apache.commons.lang3.StringUtils;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.types.State;
import org.openhab.io.imperihome.internal.model.param.DeviceParam;
import org.openhab.io.imperihome.internal.model.param.ParamType;
import org.openhab.io.imperihome.internal.util.StringUtils;
/**
* RGB light device.
@ -80,7 +80,7 @@ public class RgbLightDevice extends AbstractEnergyLinkDevice {
private String toHex(int value) {
String hex = Integer.toHexString(value);
return StringUtils.leftPad(hex, 2, '0');
return StringUtils.padLeft(hex, 2, "0");
}
private int convertPercentToByte(PercentType percent) {

View File

@ -20,7 +20,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.BooleanUtils;
import org.openhab.core.items.Item;
import org.openhab.core.items.ItemRegistry;
import org.openhab.core.items.ItemRegistryChangeListener;
@ -58,6 +57,7 @@ import org.openhab.io.imperihome.internal.model.device.WindDevice;
import org.openhab.io.imperihome.internal.model.param.DeviceParam;
import org.openhab.io.imperihome.internal.model.param.ParamType;
import org.openhab.io.imperihome.internal.util.DigestUtil;
import org.openhab.io.imperihome.internal.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -227,7 +227,7 @@ public class ItemProcessor implements ItemRegistryChangeListener {
}
private boolean isInverted(Map<TagType, List<String>> issTags) {
return issTags.containsKey(TagType.INVERT) && BooleanUtils.toBoolean(issTags.get(TagType.INVERT).get(0));
return issTags.containsKey(TagType.INVERT) && StringUtils.toBoolean(issTags.get(TagType.INVERT).get(0));
}
private void setDeviceRoom(AbstractDevice device, Map<TagType, List<String>> issTags) {

View File

@ -0,0 +1,44 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.imperihome.internal.util;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link StringUtils} class defines some static string utility methods
*
* @author Leo Siepel - Initial contribution
*/
@NonNullByDefault
public class StringUtils {
/**
* Simple method to create boolean from string.
* 'true', 'on', 'y', 't' or 'yes' (case insensitive) will return true. Otherwise, false is returned.
*/
public static boolean toBoolean(@Nullable String input) {
if (input != null) {
input = input.toLowerCase();
}
return "true".equals(input) || "on".equals(input) || "y".equals(input) || "t".equals(input)
|| "yes".equals(input);
}
public static String padLeft(@Nullable String input, int minSize, String padString) {
if (input == null) {
input = "";
}
return String.format("%" + minSize + "s", input).replace(" ", padString);
}
}