*/
package org.openhab.binding.dwdunwetter.internal.config;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
public class DwdUnwetterConfiguration {
public int refresh;
public int warningCount;
- public String cellId = StringUtils.EMPTY;
+ public String cellId = "";
}
import java.math.BigDecimal;
import java.time.Instant;
-import org.apache.commons.lang.StringUtils;
-
/**
* Data for one warning.
*
}
public boolean isTest() {
- return StringUtils.equalsIgnoreCase(status, "Test");
+ return "Test".equalsIgnoreCase(status);
}
public void setMsgType(String msgType) {
}
public boolean isCancel() {
- return StringUtils.equalsIgnoreCase(msgType, "Cancel");
+ return "Cancel".equalsIgnoreCase(msgType);
}
public void setHeadline(String headline) {
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.io.net.http.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Returns the raw Data from the Endpoint.
- * In case of errors or empty cellId value, returns an {@link StringUtils#EMPTY Empty String}.
+ * In case of errors or empty cellId value, returns an empty String.
*
* @param cellId The warnCell-Id for which the warnings should be returned
* @return The raw data received or an empty string.
*/
public String getDataFromEndpoint(String cellId) {
try {
- if (StringUtils.isBlank(cellId)) {
+ if (cellId == null || cellId.isBlank()) {
logger.warn("No cellId provided");
- return StringUtils.EMPTY;
+ return "";
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(DWD_URL);
stringBuilder.append("&CQL_FILTER=");
- stringBuilder
- .append(URLEncoder.encode("WARNCELLID LIKE '" + cellId + "'", StandardCharsets.UTF_8.toString()));
+ stringBuilder.append(URLEncoder.encode("WARNCELLID LIKE '" + cellId + "'", StandardCharsets.UTF_8));
logger.debug("Refreshing Data for cell {}", cellId);
String rawData = HttpUtil.executeUrl("GET", stringBuilder.toString(), 5000);
logger.trace("Raw request: {}", stringBuilder);
logger.debug("Communication error trace", e);
}
- return StringUtils.EMPTY;
+ return "";
}
}
import java.util.Arrays;
-import org.apache.commons.lang.StringUtils;
-
/**
* The XML Tags to extract the relevant parts from the API response.
* The names map directly to the XML Tags of the API Response.
}
public static DwdXmlTag getDwdXmlTag(String tag) {
- return Arrays.asList(DwdXmlTag.values()).stream().filter(t -> StringUtils.equals(t.getTag(), tag)).findFirst()
+ return Arrays.asList(DwdXmlTag.values()).stream().filter(t -> tag.equals(t.getTag())).findFirst()
.orElse(UNKNOWN);
}
}
import java.util.Arrays;
-import org.apache.commons.lang.StringUtils;
-
/**
* Severity enum to make the severity comparable
*
}
public static Severity getSeverity(String input) {
- return Arrays.asList(Severity.values()).stream()
- .filter(sev -> StringUtils.equalsIgnoreCase(input, sev.getText())).findAny().orElse(UNKNOWN);
+ return Arrays.asList(Severity.values()).stream().filter(sev -> input.equalsIgnoreCase(sev.getText())).findAny()
+ .orElse(UNKNOWN);
}
}
import java.util.Comparator;
-import org.apache.commons.lang.ObjectUtils;
-
/**
* Comperator to sort a Warning first by Severity, second by the onSet date.
*
int result = Integer.compare(o1.getSeverity().getOrder(), o2.getSeverity().getOrder());
if (result == 0) {
- result = ObjectUtils.compare(o1.getOnset(), o2.getOnset());
+ if (o1.getOnset() == o2.getOnset()) {
+ return 0;
+ } else if (o1.getOnset() == null) {
+ return -1;
+ } else if (o2.getOnset() == null) {
+ return 1;
+ }
+ return o1.getOnset().compareTo(o2.getOnset());
}
return result;
}
import java.util.Arrays;
-import org.apache.commons.lang.StringUtils;
-
/**
* Enum for the urgency of the warning.
*
}
public static Urgency getUrgency(String input) {
- return Arrays.asList(Urgency.values()).stream()
- .filter(urg -> StringUtils.equalsIgnoreCase(input, urg.getText())).findAny().orElse(UNKNOWN);
+ return Arrays.asList(Urgency.values()).stream().filter(urg -> input.equalsIgnoreCase(urg.getText())).findAny()
+ .orElse(UNKNOWN);
}
}
import java.io.InputStream;
import java.util.List;
+import java.util.Objects;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.commons.lang.StringUtils;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
if (nodeId == null) {
continue;
}
- if (StringUtils.equals(nodeId.getTextContent(), uuid.getId())) {
+ if (Objects.equals(nodeId.getTextContent(), uuid.getId())) {
return getLabel(node.getChildNodes());
}
}