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.
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) {
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;
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;
}
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) {
--- /dev/null
+/**
+ * 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);
+ }
+}