]> git.basschouten.com Git - openhab-addons.git/commitdiff
[ecobee] adapt to core StringUtils (#15762)
authorlsiepel <leosiepel@gmail.com>
Thu, 19 Oct 2023 19:41:22 +0000 (21:41 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Oct 2023 19:41:22 +0000 (21:41 +0200)
* adapt to core StringUtils

---------

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/handler/EcobeeSensorThingHandler.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/handler/EcobeeThermostatBridgeHandler.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/util/StringUtils.java [deleted file]

index c3353276d1a5596d102e40fdab5d17133de20e65..f05f140d25161aef8be0b841ce2196416ff46392 100644 (file)
@@ -21,7 +21,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.ecobee.internal.config.EcobeeSensorConfiguration;
 import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorCapabilityDTO;
 import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorDTO;
-import org.openhab.binding.ecobee.internal.util.StringUtils;
 import org.openhab.core.library.unit.Units;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelUID;
@@ -37,6 +36,7 @@ import org.openhab.core.types.Command;
 import org.openhab.core.types.RefreshType;
 import org.openhab.core.types.State;
 import org.openhab.core.types.UnDefType;
+import org.openhab.core.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -126,7 +126,7 @@ public class EcobeeSensorThingHandler extends BaseThingHandler {
             ThingBuilder thingBuilder;
             thingBuilder = editThing();
             channel = ChannelBuilder.create(uid, getAcceptedItemType(capability.type))
-                    .withLabel("Sensor " + StringUtils.capitalizeWords(capability.type))
+                    .withLabel("Sensor " + StringUtils.capitalizeByWhitespace(capability.type))
                     .withType(getChannelTypeUID(capability.type)).build();
             thingBuilder.withChannel(channel);
             updateThing(thingBuilder.build());
index 91fbfcdc29fcc24e831c6e1b7c5585116f0316ac..5b4506e97365facaad73b92eab40583359258720 100644 (file)
@@ -49,7 +49,6 @@ import org.openhab.binding.ecobee.internal.dto.thermostat.WeatherDTO;
 import org.openhab.binding.ecobee.internal.dto.thermostat.WeatherForecastDTO;
 import org.openhab.binding.ecobee.internal.function.AbstractFunction;
 import org.openhab.binding.ecobee.internal.function.FunctionRequest;
-import org.openhab.binding.ecobee.internal.util.StringUtils;
 import org.openhab.core.i18n.TimeZoneProvider;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
@@ -74,6 +73,7 @@ import org.openhab.core.thing.type.ChannelTypeUID;
 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;
 
@@ -179,7 +179,8 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
             for (Channel channel : thing.getChannelsOfGroup(group)) {
                 if (isLinked(channel.getUID())) {
                     try {
-                        Field field = selection.getClass().getField("include" + StringUtils.capitalizeWords(group));
+                        Field field = selection.getClass()
+                                .getField("include" + StringUtils.capitalizeByWhitespace(group));
                         logger.trace("ThermostatBridge: Thermostat thing '{}' including object '{}' in selection",
                                 thing.getUID(), field.getName());
                         field.set(selection, Boolean.TRUE);
diff --git a/bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/util/StringUtils.java b/bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/util/StringUtils.java
deleted file mode 100644 (file)
index 10460da..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.binding.ecobee.internal.util;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * The {@link StringUtils} class defines static string related methods
- *
- * @author Leo Siepel - Initial contribution
- */
-@NonNullByDefault
-public class StringUtils {
-
-    public static String capitalizeWords(@Nullable String input) {
-        String output = "";
-        if (input != null) {
-            String[] splitted = input.split("\\s+");
-            String[] processed = new String[splitted.length];
-            for (int wordIndex = 0; wordIndex < splitted.length; wordIndex++) {
-                if (splitted[wordIndex].length() > 1) {
-                    processed[wordIndex] = splitted[wordIndex].substring(0, 1).toUpperCase()
-                            + splitted[wordIndex].substring(1);
-                } else {
-                    processed[wordIndex] = splitted[wordIndex].toUpperCase();
-                }
-            }
-            output = String.join(" ", processed);
-        }
-        return output;
-    }
-}