Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## Release in-progress

### API Changes
* Add addAll method to MutableContainer and subclasses
* Add addAll method to MutableContainer and subclasses #1782.
* Deprecate com.github.bordertech.wcomponents.util.Util, and replace usage with methods in existing dependencies #1622 #1785.

### Enhancements
### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.bordertech.wcomponents;

import com.github.bordertech.wcomponents.util.ConfigurationProperties;
import com.github.bordertech.wcomponents.util.Util;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -100,7 +100,7 @@ private String getServletPath(final String relativePath) {

String context = getHostFreeBaseUrl();

if (!Util.empty(context)) {
if (StringUtils.isNotBlank(context)) {
return context + relativePath;
}

Expand All @@ -115,7 +115,7 @@ public String getThemePath() {
String themePath = ConfigurationProperties.getThemeContentPath();

// No theme path, so use the main servlet to feed up the theme resources
if (Util.empty(themePath)) {
if (StringUtils.isBlank(themePath)) {
String path = getWServletPath() + "/" + Environment.THEME_RESOURCE_PATH_NAME;
return path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import com.github.bordertech.wcomponents.util.Config;
import com.github.bordertech.wcomponents.util.Enumerator;
import com.github.bordertech.wcomponents.util.StreamUtil;
import com.github.bordertech.wcomponents.util.Util;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.fileupload.FileItem;

/**
Expand Down Expand Up @@ -101,7 +101,7 @@ public boolean containsSameData(final Request other) {

Map ours = getParameters();
Map theirs = ((AbstractRequest) other).getParameters();
return Util.equals(ours, theirs);
return Objects.equals(ours, theirs);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.util.I18nUtilities;
import com.github.bordertech.wcomponents.util.SystemException;
import com.github.bordertech.wcomponents.util.Util;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import com.github.bordertech.wcomponents.validation.DiagnosticImpl;
import com.github.bordertech.wcomponents.velocity.VelocityTemplateManager;
Expand All @@ -28,6 +27,7 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;

/**
* <p>
Expand Down Expand Up @@ -146,7 +146,7 @@ public String getIdName() {
@Override
public void setIdName(final String idName) {
// Not allow empty or null
if (Util.empty(idName)) {
if (StringUtils.isBlank(idName)) {
throw new IllegalArgumentException("idName cannot be null or empty");
}

Expand Down Expand Up @@ -1673,7 +1673,7 @@ public void setHtmlClass(final HtmlClassProperties className) {
*/
@Override
public void addHtmlClass(final String className) {
if (!Util.empty(className)) {
if (StringUtils.isNotBlank(className)) {
getOrCreateComponentModel().addHtmlClass(className);
}
}
Expand Down Expand Up @@ -1757,7 +1757,7 @@ final String toString(final String details, final int childStartIndex, final int
// which is not particularly useful, so we recurse until we find a suitable one.
String className = null;

for (Class<?> clazz = getClass(); Util.empty(className) && clazz != null; clazz = clazz.
for (Class<?> clazz = getClass(); StringUtils.isBlank(className) && clazz != null; clazz = clazz.
getSuperclass()) {
className = clazz.getSimpleName();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.bordertech.wcomponents;

import com.github.bordertech.wcomponents.util.InternalMessages;
import com.github.bordertech.wcomponents.util.Util;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -513,7 +513,7 @@ protected List<?> getNewSelections(final Request request) {
*/
private boolean selectionsEqual(final List<?> list1, final List<?> list2) {
if (isSelectionOrderable()) {
return Util.equals(list1, list2);
return Objects.equals(list1, list2);
}

// Empty or null lists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import com.github.bordertech.wcomponents.util.I18nUtilities;
import com.github.bordertech.wcomponents.util.LookupTable;
import com.github.bordertech.wcomponents.util.LookupTableHelper;
import com.github.bordertech.wcomponents.util.Util;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* AbstractWSelectList provides the basis for components that allow the user to select an item from a list.
Expand Down Expand Up @@ -185,7 +185,7 @@ protected int getOptionIndex(final Object option) {
}

optionCount += groupOptions.size();
} else if (Util.equals(option, obj)) {
} else if (Objects.equals(option, obj)) {
return optionCount;
} else {
optionCount++;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.bordertech.wcomponents;

import com.github.bordertech.wcomponents.util.Util;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -220,7 +220,7 @@ protected boolean doHandleRequest(final Request request) {
final Object newSelection = getRequestValue(request);
final Object priorSelection = getValue();

boolean changed = !Util.equals(newSelection, priorSelection);
boolean changed = !Objects.equals(newSelection, priorSelection);

if (changed) {
setData(newSelection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.util.I18nUtilities;
import com.github.bordertech.wcomponents.util.ReflectionUtil;
import com.github.bordertech.wcomponents.util.Util;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
Expand All @@ -20,8 +19,10 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.Stack;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -279,7 +280,7 @@ public boolean equals(final Object obj) {
Object value = fields[i].get(this);
Object otherValue = fields[i].get(obj);

if (!Util.equals(value, otherValue)) {
if (!Objects.equals(value, otherValue)) {
return false;
}
}
Expand Down Expand Up @@ -587,7 +588,7 @@ protected void setHtmlClass(final HtmlClassProperties className) {
* @param text The HTML class name text to set.
*/
protected void addHtmlClass(final String text) {
if (!Util.empty(text)) {
if (StringUtils.isNotBlank(text)) {
if (this.htmlClasses == null) {
this.htmlClasses = new HashSet<>();
}
Expand Down Expand Up @@ -616,7 +617,7 @@ protected Set getHtmlClasses() {
* @param className the value to remove
*/
protected void removeHtmlClass(final String className) {
if (this.htmlClasses != null && !Util.empty(className)) {
if (this.htmlClasses != null && StringUtils.isNotBlank(className)) {
this.htmlClasses.remove(className);
}
}
Expand Down Expand Up @@ -753,7 +754,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
Object sharedValue = field.get(sharedModel);
Object value = field.get(this);

if (Util.equals(value, sharedValue)) {
if (Objects.equals(value, sharedValue)) {
out.writeObject(NoOverride.INSTANCE);
} else {
out.writeObject(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.bordertech.wcomponents;

import com.github.bordertech.wcomponents.util.I18nUtilities;
import com.github.bordertech.wcomponents.util.Util;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Objects;

/**
* Message - encapsulates a simple message that is to be displayed to the user.
Expand Down Expand Up @@ -139,7 +139,7 @@ public boolean equals(final Object obj) {
Message other = (Message) obj;

return type == other.type
&& Util.equals(message, other.message)
&& Objects.equals(message, other.message)
&& Arrays.equals(args, other.args);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.bordertech.wcomponents;

import com.github.bordertech.wcomponents.util.Util;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -49,7 +50,7 @@ public String getValue() {
return null;
}
// An empty string is treated as null
return Util.empty(data.toString()) ? null : data.toString();
return StringUtils.isBlank(data.toString()) ? null : data.toString();
}

/**
Expand Down Expand Up @@ -92,7 +93,7 @@ boolean handleButtonOnRequest(final Request request) {
String value = getRequestValue(request);
String current = getValue();

boolean changed = !Util.equals(value, current);
boolean changed = !Objects.equals(value, current);

if (changed) {
setChangedInLastRequest(true);
Expand Down Expand Up @@ -120,7 +121,7 @@ public String getRequestValue(final Request request) {
if (isPresent(request)) {
String value = request.getParameter(getId());
// Treat empty as null
return Util.empty(value) ? null : value;
return StringUtils.isBlank(value) ? null : value;
} else {
return getValue();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.bordertech.wcomponents;

import com.github.bordertech.wcomponents.util.Util;
import java.util.List;
import java.util.Objects;

/**
* Utility class used by {@link AbstractWSelectList} for processing options and list of options.
Expand Down Expand Up @@ -32,12 +32,12 @@ public static boolean containsOption(final List<?> options, final Object findOpt
List<?> groupOptions = ((OptionGroup) option).getOptions();
if (groupOptions != null) {
for (Object nestedOption : groupOptions) {
if (Util.equals(nestedOption, findOption)) {
if (Objects.equals(nestedOption, findOption)) {
return true;
}
}
}
} else if (Util.equals(option, findOption)) {
} else if (Objects.equals(option, findOption)) {
return true;
}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public static Object getOptionWithMatching(final List<?> options, final Object d
if (groupOptions != null) {
for (Object nestedOption : groupOptions) {
// Check for match via equals/code
if (Util.equals(nestedOption, data) || isOptionCodeMatch(nestedOption,
if (Objects.equals(nestedOption, data) || isOptionCodeMatch(nestedOption,
data)) {
return nestedOption;
}
Expand All @@ -108,7 +108,7 @@ public static Object getOptionWithMatching(final List<?> options, final Object d
}
} else {
// Check for match via equals/code
if (Util.equals(option, data) || isOptionCodeMatch(option, data)) {
if (Objects.equals(option, data) || isOptionCodeMatch(option, data)) {
return option;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ public static Object getFirstOption(final List<?> options) {
* @return true if the option and data are a match
*/
private static boolean isEqualWithMatching(final Object option, final Object data) {
return Util.equals(option, data) || isOptionCodeMatch(option, data) || isLegacyMatch(option,
return Objects.equals(option, data) || isOptionCodeMatch(option, data) || isLegacyMatch(option,
data);
}

Expand All @@ -177,7 +177,7 @@ private static boolean isLegacyMatch(final Object option, final Object data) {
// Support legacy matching, which supported setSelected using String representations...
String optionAsString = String.valueOf(option);
String matchAsString = String.valueOf(data);
boolean equal = Util.equals(optionAsString, matchAsString);
boolean equal = Objects.equals(optionAsString, matchAsString);
return equal;
}

Expand All @@ -193,7 +193,7 @@ private static boolean isOptionCodeMatch(final Object option, final Object data)
if (option instanceof Option) {
String optionCode = ((Option) option).getCode();
String matchAsString = String.valueOf(data);
boolean equal = Util.equals(optionCode, matchAsString);
boolean equal = Objects.equals(optionCode, matchAsString);
return equal;
}
return false;
Expand Down
Loading