Deprecate StringUtils::trimWhitespace and variants

This commits deprecates
- StringUtils::trimWhitespace in favor of String::strip
- StringUtils::trimLeadingWhitespace in favor of String::stripLeading
- StringUtils::trimTrailingWhitespace in favor of String::stripTrailing

Closes gh-27769
This commit is contained in:
Arjen Poutsma
2021-12-06 13:33:30 +01:00
parent 982ba0e86d
commit 81af7330f6
10 changed files with 28 additions and 21 deletions

View File

@@ -428,31 +428,31 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
int beginIndex = prefixWithSep.length();
for (Map.Entry<?, ?> entry : map.entrySet()) {
String key = StringUtils.trimWhitespace((String) entry.getKey());
String key = ((String) entry.getKey()).strip();
if (key.startsWith(prefixWithSep)) {
String property = key.substring(beginIndex);
if (CLASS_KEY.equals(property)) {
className = StringUtils.trimWhitespace((String) entry.getValue());
className = ((String) entry.getValue()).strip();
}
else if (PARENT_KEY.equals(property)) {
parent = StringUtils.trimWhitespace((String) entry.getValue());
parent = ((String) entry.getValue()).strip();
}
else if (ABSTRACT_KEY.equals(property)) {
String val = StringUtils.trimWhitespace((String) entry.getValue());
String val = ((String) entry.getValue()).strip();
isAbstract = TRUE_VALUE.equals(val);
}
else if (SCOPE_KEY.equals(property)) {
// Spring 2.0 style
scope = StringUtils.trimWhitespace((String) entry.getValue());
scope = ((String) entry.getValue()).strip();
}
else if (SINGLETON_KEY.equals(property)) {
// Spring 1.2 style
String val = StringUtils.trimWhitespace((String) entry.getValue());
String val = ((String) entry.getValue()).strip();
scope = (!StringUtils.hasLength(val) || TRUE_VALUE.equals(val) ?
BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
}
else if (LAZY_INIT_KEY.equals(property)) {
String val = StringUtils.trimWhitespace((String) entry.getValue());
String val = ((String) entry.getValue()).strip();
lazyInit = TRUE_VALUE.equals(val);
}
else if (property.startsWith(CONSTRUCTOR_ARG_PREFIX)) {
@@ -469,7 +469,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
// This isn't a real property, but a reference to another prototype
// Extract property name: property is of form dog(ref)
property = property.substring(0, property.length() - REF_SUFFIX.length());
String ref = StringUtils.trimWhitespace((String) entry.getValue());
String ref = ((String) entry.getValue()).strip();
// It doesn't matter if the referenced bean hasn't yet been registered:
// this will ensure that the reference is resolved at runtime.

View File

@@ -79,8 +79,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
if (node instanceof Attr attr) {
String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
String argValue = StringUtils.trimWhitespace(attr.getValue());
String argName = parserContext.getDelegate().getLocalName(attr).strip();
String argValue = attr.getValue().strip();
ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
boolean ref = false;