*/
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;
* @return a string containing the module device type
*/
public String getDeviceType() {
- return StringUtil.capitalizeAll(deviceType);
+ return StringUtils.capitalizeByWhitespace(deviceType);
}
/**
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;
// 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)));
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;
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}.