Deprecate StringUtils.isEmpty(Object) and replace remaining usage
Closes gh-25945
This commit is contained in:
parent
07769ddcc6
commit
621295dbd8
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -40,7 +40,6 @@ import org.springframework.lang.Nullable;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link AutowireCandidateResolver} implementation that matches bean definition qualifiers
|
||||
|
|
@ -188,7 +187,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
|||
foundMeta = true;
|
||||
// Only accept fallback match if @Qualifier annotation has a value...
|
||||
// Otherwise it is just a marker for a custom qualifier annotation.
|
||||
if ((fallbackToMeta && StringUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) ||
|
||||
if ((fallbackToMeta && ObjectUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) ||
|
||||
!checkQualifier(bdHolder, metaAnn, typeConverter)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@ public abstract class ObjectUtils {
|
|||
* @see Optional#isPresent()
|
||||
* @see ObjectUtils#isEmpty(Object[])
|
||||
* @see StringUtils#hasLength(CharSequence)
|
||||
* @see StringUtils#isEmpty(Object)
|
||||
* @see CollectionUtils#isEmpty(java.util.Collection)
|
||||
* @see CollectionUtils#isEmpty(java.util.Map)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -91,9 +91,10 @@ public abstract class StringUtils {
|
|||
* {@link #hasLength(String)} or {@link #hasText(String)} instead.</b>
|
||||
* @param str the candidate object (possibly a {@code String})
|
||||
* @since 3.2.1
|
||||
* @see #hasLength(String)
|
||||
* @see #hasText(String)
|
||||
* @deprecated as of 5.3, in favor of {@link #hasLength(String)} and
|
||||
* {@link #hasText(String)} (or {@link ObjectUtils#isEmpty(Object)})
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isEmpty(@Nullable Object str) {
|
||||
return (str == null || "".equals(str));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.springframework.expression.spel.CodeFlow;
|
|||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents the elvis operator ?:. For an expression "a?:b" if a is not null, the value
|
||||
|
|
@ -52,7 +51,7 @@ public class Elvis extends SpelNodeImpl {
|
|||
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
||||
TypedValue value = this.children[0].getValueInternal(state);
|
||||
// If this check is changed, the generateCode method will need changing too
|
||||
if (!StringUtils.isEmpty(value.getValue())) {
|
||||
if (value.getValue() != null && !"".equals(value.getValue())) {
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import org.springframework.scheduling.TaskScheduler;
|
|||
import org.springframework.util.AlternativeJdkIdGenerator;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.IdGenerator;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||
|
|
@ -263,7 +264,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
|
|||
private Message<byte[]> createMessage(StompHeaderAccessor accessor, @Nullable Object payload) {
|
||||
accessor.updateSimpMessageHeadersFromStompHeaders();
|
||||
Message<byte[]> message;
|
||||
if (StringUtils.isEmpty(payload) || (payload instanceof byte[] && ((byte[]) payload).length == 0)) {
|
||||
if (ObjectUtils.isEmpty(payload)) {
|
||||
message = MessageBuilder.createMessage(EMPTY_PAYLOAD, accessor.getMessageHeaders());
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -683,13 +683,12 @@ class Jackson2ObjectMapperBuilderTests {
|
|||
|
||||
@Override
|
||||
public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
final String value = jsonParser.getValueAsString();
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
String value = jsonParser.getValueAsString();
|
||||
if (!StringUtils.hasLength(value)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OffsetDateTime.parse(value);
|
||||
|
||||
}
|
||||
catch (DateTimeParseException exception) {
|
||||
return OffsetDateTime.parse(value + CURRENT_ZONE_OFFSET);
|
||||
|
|
|
|||
|
|
@ -129,10 +129,10 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgu
|
|||
if (requestPart != null) {
|
||||
name = requestPart.name();
|
||||
}
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
name = methodParam.getParameterName();
|
||||
}
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
throw new IllegalArgumentException("Request part name for argument type [" +
|
||||
methodParam.getNestedParameterType().getName() +
|
||||
"] not specified, and parameter name information not found in class file either.");
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public final class CloseStatus {
|
|||
* @since 5.3
|
||||
*/
|
||||
public static CloseStatus create(int code, @Nullable String reason) {
|
||||
if (StringUtils.isEmpty(reason)) {
|
||||
if (!StringUtils.hasText(reason)) {
|
||||
switch (code) {
|
||||
case 1000:
|
||||
return NORMAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue