diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Module.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Module.java index 5efa40168423e..ca79ca8976c0c 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Module.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Module.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.bticinosmarther.internal.api.dto; -import org.openhab.binding.bticinosmarther.internal.util.StringUtil; +import org.openhab.core.util.StringUtils; import com.google.gson.annotations.SerializedName; @@ -34,7 +34,7 @@ public class Module { * @return a string containing the module device type */ public String getDeviceType() { - return StringUtil.capitalizeAll(deviceType); + return StringUtils.capitalizeByWhitespace(deviceType); } /** diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/handler/SmartherModuleHandler.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/handler/SmartherModuleHandler.java index 13ae557b6ffe5..921d69452c633 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/handler/SmartherModuleHandler.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/handler/SmartherModuleHandler.java @@ -53,6 +53,7 @@ import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; import org.openhab.core.types.State; +import org.openhab.core.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -709,9 +710,9 @@ private void updateModuleStatus() throws SmartherIllegalPropertyValueException { // Update the Status channels updateChannelState(CHANNEL_STATUS_STATE, (localChrono.isActive() ? OnOffType.ON : OnOffType.OFF)); updateChannelState(CHANNEL_STATUS_FUNCTION, - new StringType(StringUtil.capitalize(localChrono.getFunction().toLowerCase()))); + new StringType(StringUtils.capitalize(localChrono.getFunction().toLowerCase()))); updateChannelState(CHANNEL_STATUS_MODE, - new StringType(StringUtil.capitalize(localChrono.getMode().toLowerCase()))); + new StringType(StringUtils.capitalize(localChrono.getMode().toLowerCase()))); updateChannelState(CHANNEL_STATUS_TEMPERATURE, localChrono.getSetPointTemperature().toState()); updateChannelState(CHANNEL_STATUS_ENDTIME, new StringType(localChrono.getActivationTimeLabel(timeZoneProvider))); diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/StringUtil.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/StringUtil.java index 8a0af0103c900..3a48a1dd8acde 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/StringUtil.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/StringUtil.java @@ -17,8 +17,6 @@ import java.io.InputStreamReader; import java.io.Reader; import java.io.StringWriter; -import java.util.Arrays; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -90,43 +88,6 @@ public static String defaultIfBlank(String str, String defaultStr) { return (s.isEmpty()) ? null : s; } - /** - * Capitalizes a string changing the first letter to title case as per {@link Character#toTitleCase(char)}. No other - * letters are changed. - * - * @param str - * the string to capitalize, may be {@code null} - * - * @return the capitalized string, {@code null} if {@code null} input string - */ - public static @Nullable String capitalize(@Nullable String str) { - if (str == null || str.isEmpty()) { - return str; - } - return str.substring(0, 1).toUpperCase() + str.substring(1); - } - - /** - * Converts all the whitespace separated words in a string into capitalized words, that is each word is made up of a - * titlecase character and then a series of lowercase characters. - * - * @param str - * the string to capitalize, may be {@code null} - * - * @return the capitalized string, {@code null} if {@code null} input string - */ - public static @Nullable String capitalizeAll(@Nullable String str) { - if (str == null || str.isEmpty()) { - return str; - } - // Java 8 version - return Arrays.stream(str.split("\\s+")).map(t -> t.substring(0, 1).toUpperCase() + t.substring(1).toLowerCase()) - .collect(Collectors.joining(" ")); - // Ready for Java 9+ - // return Pattern.compile("\\b(.)(.*?)\\b").matcher(str) - // .replaceAll(match -> match.group(1).toUpperCase() + match.group(2).toLowerCase()); - } - /** * Get the contents of an {@link InputStream} stream as a string using the default character encoding of the * platform. This method buffers the input internally, so there is no need to use a {@code BufferedInputStream}.