Skip to content

Commit 009d879

Browse files
committed
do no longer use lang3 StringUtils.isNotEmpty
1 parent b117b86 commit 009d879

8 files changed

Lines changed: 28 additions & 23 deletions

File tree

src/main/java/org/htmlunit/html/HtmlMonthInput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import java.time.format.DateTimeParseException;
2323
import java.util.Map;
2424

25-
import org.apache.commons.lang3.StringUtils;
2625
import org.htmlunit.BrowserVersion;
2726
import org.htmlunit.SgmlPage;
27+
import org.htmlunit.util.StringUtils;
2828

2929
/**
3030
* Wrapper for the HTML element "input" where type is "month".
@@ -63,7 +63,7 @@ public void setDefaultChecked(final boolean defaultChecked) {
6363
@Override
6464
public void setValue(final String newValue) {
6565
try {
66-
if (hasFeature(HTMLINPUT_TYPE_MONTH_SUPPORTED) && StringUtils.isNotEmpty(newValue)) {
66+
if (hasFeature(HTMLINPUT_TYPE_MONTH_SUPPORTED) && !StringUtils.isEmptyOrNull(newValue)) {
6767
FORMATTER_.parse(newValue);
6868
}
6969
super.setValue(newValue);

src/main/java/org/htmlunit/html/HtmlRangeInput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import java.util.Map;
1818

19-
import org.apache.commons.lang3.StringUtils;
2019
import org.htmlunit.SgmlPage;
20+
import org.htmlunit.util.StringUtils;
2121

2222
/**
2323
* Wrapper for the HTML element "input" where type is "range".
@@ -122,7 +122,7 @@ public void setDefaultChecked(final boolean defaultChecked) {
122122
@Override
123123
public void setValue(final String newValue) {
124124
try {
125-
if (StringUtils.isNotEmpty(newValue)) {
125+
if (!StringUtils.isEmptyOrNull(newValue)) {
126126
setValue(Double.parseDouble(newValue));
127127
}
128128
else {
@@ -177,7 +177,7 @@ protected void valueAttributeChanged(final String attributeValue, final boolean
177177
}
178178

179179
try {
180-
if (StringUtils.isNotEmpty(attributeValue)) {
180+
if (!org.htmlunit.util.StringUtils.isEmptyOrNull(attributeValue)) {
181181
setRawValue(Double.parseDouble(attributeValue));
182182
}
183183
else {

src/main/java/org/htmlunit/javascript/host/html/HTMLDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ public Selection getSelection() {
736736
@Override
737737
public Attr createAttribute(final String attributeName) {
738738
String name = attributeName;
739-
if (StringUtils.isNotEmpty(name)) {
739+
if (!org.htmlunit.util.StringUtils.isEmptyOrNull(name)) {
740740
name = org.htmlunit.util.StringUtils.toRootLowerCase(name);
741741
}
742742

src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.Set;
3232

3333
import org.apache.commons.lang3.ArrayUtils;
34-
import org.apache.commons.lang3.StringUtils;
3534
import org.htmlunit.SgmlPage;
3635
import org.htmlunit.corejs.javascript.Function;
3736
import org.htmlunit.corejs.javascript.ScriptableObject;
@@ -110,6 +109,7 @@
110109
import org.htmlunit.javascript.host.event.Event;
111110
import org.htmlunit.javascript.host.event.EventHandler;
112111
import org.htmlunit.javascript.host.event.MouseEvent;
112+
import org.htmlunit.util.StringUtils;
113113

114114
/**
115115
* The JavaScript object {@code HTMLElement} which is the base class for all HTML
@@ -322,14 +322,12 @@ public String getLocalName() {
322322
final String prefix = domNode.getPrefix();
323323
if (prefix != null) {
324324
// create string builder only if needed (performance)
325-
final StringBuilder localName = new StringBuilder(
326-
org.htmlunit.util.StringUtils.toRootLowerCase(prefix))
325+
final StringBuilder localName = new StringBuilder(StringUtils.toRootLowerCase(prefix))
327326
.append(':')
328-
.append(org.htmlunit.util.StringUtils
329-
.toRootLowerCase(domNode.getLocalName()));
327+
.append(StringUtils.toRootLowerCase(domNode.getLocalName()));
330328
return localName.toString();
331329
}
332-
return org.htmlunit.util.StringUtils.toRootLowerCase(domNode.getLocalName());
330+
return StringUtils.toRootLowerCase(domNode.getLocalName());
333331
}
334332
return domNode.getLocalName();
335333
}
@@ -407,7 +405,7 @@ public void setInnerText(final Object value) {
407405
final SgmlPage page = domNode.getPage();
408406
domNode.removeAllChildren();
409407

410-
if (StringUtils.isNotEmpty(valueString)) {
408+
if (!StringUtils.isEmptyOrNull(valueString)) {
411409
final String[] parts = valueString.split("\\r?\\n");
412410
for (int i = 0; i < parts.length; i++) {
413411
if (i != 0) {
@@ -446,7 +444,7 @@ public void setOuterText(final Object value) {
446444
final DomNode domNode = getDomNodeOrDie();
447445
final SgmlPage page = domNode.getPage();
448446

449-
if (org.htmlunit.util.StringUtils.isEmptyOrNull(valueString)) {
447+
if (!StringUtils.isEmptyOrNull(valueString)) {
450448
domNode.getParentNode().insertBefore(new DomText(page, ""), domNode);
451449
}
452450
else {
@@ -473,7 +471,7 @@ public void setTextContent(final Object value) {
473471

474472
if (value != null) {
475473
final String textValue = JavaScriptEngine.toString(value);
476-
if (StringUtils.isNotEmpty(textValue)) {
474+
if (!StringUtils.isEmptyOrNull(textValue)) {
477475
domNode.appendChild(new DomText(domNode.getPage(), textValue));
478476
}
479477
}

src/main/java/org/htmlunit/javascript/host/html/HTMLInputElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.io.IOException;
2222

23-
import org.apache.commons.lang3.StringUtils;
2423
import org.apache.commons.lang3.math.NumberUtils;
2524
import org.htmlunit.html.DomElement;
2625
import org.htmlunit.html.DomNode;
@@ -43,6 +42,7 @@
4342
import org.htmlunit.javascript.host.dom.NodeList;
4443
import org.htmlunit.javascript.host.event.Event;
4544
import org.htmlunit.javascript.host.file.FileList;
45+
import org.htmlunit.util.StringUtils;
4646

4747
/**
4848
* The JavaScript object for {@link HtmlInput}.
@@ -107,7 +107,7 @@ public void setValue(final Object newValue) {
107107

108108
final String val = JavaScriptEngine.toString(newValue);
109109
if ("file".equals(getType())) {
110-
if (StringUtils.isNotEmpty(val)) {
110+
if (!StringUtils.isEmptyOrNull(val)) {
111111
throw JavaScriptEngine.asJavaScriptException(
112112
getWindow(),
113113
"Failed to set the 'value' property on 'HTMLInputElement'.",

src/main/java/org/htmlunit/javascript/host/intl/NumberFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.Map;
2222
import java.util.concurrent.ConcurrentHashMap;
2323

24-
import org.apache.commons.lang3.StringUtils;
2524
import org.htmlunit.BrowserVersion;
2625
import org.htmlunit.corejs.javascript.Context;
2726
import org.htmlunit.corejs.javascript.Function;
@@ -34,6 +33,7 @@
3433
import org.htmlunit.javascript.configuration.JsxConstructor;
3534
import org.htmlunit.javascript.configuration.JsxFunction;
3635
import org.htmlunit.javascript.host.Window;
36+
import org.htmlunit.util.StringUtils;
3737

3838
/**
3939
* A JavaScript object for {@code NumberFormat}.
@@ -220,7 +220,7 @@ static final class NumberFormatHelper {
220220

221221
NumberFormatHelper(final String localeName, final BrowserVersion browserVersion, final String pattern) {
222222
Locale locale = browserVersion.getBrowserLocale();
223-
if (StringUtils.isNotEmpty(localeName)) {
223+
if (!StringUtils.isEmptyOrNull(localeName)) {
224224
locale = Locale.forLanguageTag(localeName);
225225
}
226226

src/main/java/org/htmlunit/javascript/host/xml/XMLHttpRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import javax.xml.transform.stream.StreamResult;
4444

4545
import org.apache.commons.io.IOUtils;
46-
import org.apache.commons.lang3.StringUtils;
4746
import org.apache.commons.logging.Log;
4847
import org.apache.commons.logging.LogFactory;
4948
import org.htmlunit.AjaxController;
@@ -90,6 +89,7 @@
9089
import org.htmlunit.util.EncodingSniffer;
9190
import org.htmlunit.util.MimeType;
9291
import org.htmlunit.util.NameValuePair;
92+
import org.htmlunit.util.StringUtils;
9393
import org.htmlunit.util.UrlUtils;
9494
import org.htmlunit.util.WebResponseWrapper;
9595
import org.htmlunit.util.XUserDefinedCharset;
@@ -821,7 +821,7 @@ private void prepareRequestContent(final Object content) {
821821
final Element docElement = ((Document) content).getDocumentElement();
822822
final SgmlPage page = docElement.getDomNodeOrDie().getPage();
823823
final DocumentType doctype = page.getDoctype();
824-
if (doctype != null && StringUtils.isNotEmpty(doctype.getName())) {
824+
if (doctype != null && !StringUtils.isEmptyOrNull(doctype.getName())) {
825825
body = "<!DOCTYPE " + doctype.getName() + ">" + body;
826826
}
827827

@@ -1125,7 +1125,7 @@ private boolean isPreflightAuthorized(final WebResponse preflightResponse) {
11251125
final String[] values = org.htmlunit.util.StringUtils.splitAtComma(value);
11261126
for (String part : values) {
11271127
part = part.trim();
1128-
if (StringUtils.isNotEmpty(part)) {
1128+
if (!org.htmlunit.util.StringUtils.isEmptyOrNull(part)) {
11291129
accessControlValues.add(part);
11301130
}
11311131
}

src/test/java/org/htmlunit/archunit/ArchitectureTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,19 @@ public class ArchitectureTest {
120120
.should().callMethod(org.apache.commons.lang3.StringUtils.class, "toRootLowerCase", String.class);
121121

122122
/**
123-
* Do not use org.apache.commons.lang3.StringUtils.toRootLowerCase(String).
123+
* Do not use org.apache.commons.lang3.StringUtils.substringBefore(String, string).
124124
*/
125125
@ArchTest
126126
public static final ArchRule apacheStringUtilsSubstringBeforeRule = noClasses()
127127
.should().callMethod(org.apache.commons.lang3.StringUtils.class, "substringBefore", String.class, String.class);
128128

129+
/**
130+
* Do not use org.apache.commons.lang3.StringUtils.isNotEmpty(String).
131+
*/
132+
@ArchTest
133+
public static final ArchRule apacheStringUtilsIsNotEmptyRule = noClasses()
134+
.should().callMethod(org.apache.commons.lang3.StringUtils.class, "isNotEmpty", CharSequence.class);
135+
129136
/**
130137
* Do not use org.apache.commons.lang3.Strings.startsWith(CharSequence, CharSequence).
131138
*/

0 commit comments

Comments
 (0)