Consistent use of StringUtils.hasLength(String) vs isEmpty(Object)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -357,11 +357,10 @@ public class MvcUriComponentsBuilder {
|
||||
RequestMappingInfoHandlerMapping handlerMapping = getRequestMappingInfoHandlerMapping();
|
||||
List<HandlerMethod> handlerMethods = handlerMapping.getHandlerMethodsForMappingName(name);
|
||||
if (handlerMethods == null) {
|
||||
throw new IllegalArgumentException("Mapping mappingName not found: " + name);
|
||||
throw new IllegalArgumentException("Mapping not found: " + name);
|
||||
}
|
||||
if (handlerMethods.size() != 1) {
|
||||
throw new IllegalArgumentException("No unique match for mapping mappingName " +
|
||||
name + ": " + handlerMethods);
|
||||
throw new IllegalArgumentException("No unique match for mapping " + name + ": " + handlerMethods);
|
||||
}
|
||||
HandlerMethod handlerMethod = handlerMethods.get(0);
|
||||
Class<?> controllerType = handlerMethod.getBeanType();
|
||||
@@ -440,7 +439,7 @@ public class MvcUriComponentsBuilder {
|
||||
return "/";
|
||||
}
|
||||
String[] paths = requestMapping.path();
|
||||
if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) {
|
||||
if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) {
|
||||
return "/";
|
||||
}
|
||||
if (paths.length > 1 && logger.isWarnEnabled()) {
|
||||
@@ -456,7 +455,7 @@ public class MvcUriComponentsBuilder {
|
||||
throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString());
|
||||
}
|
||||
String[] paths = requestMapping.path();
|
||||
if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) {
|
||||
if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) {
|
||||
return "/";
|
||||
}
|
||||
if (paths.length > 1 && logger.isWarnEnabled()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -125,7 +125,7 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
|
||||
}
|
||||
|
||||
PathVariable ann = parameter.getParameterAnnotation(PathVariable.class);
|
||||
String name = (ann != null && !StringUtils.isEmpty(ann.value()) ? ann.value() : parameter.getParameterName());
|
||||
String name = (ann != null && StringUtils.hasLength(ann.value()) ? ann.value() : parameter.getParameterName());
|
||||
String formatted = formatUriValue(conversionService, new TypeDescriptor(parameter.nestedIfOptional()), value);
|
||||
uriVariables.put(name, formatted);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -168,7 +168,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
|
||||
}
|
||||
|
||||
String candidateVersion = versionStrategy.extractVersion(requestPath);
|
||||
if (StringUtils.isEmpty(candidateVersion)) {
|
||||
if (!StringUtils.hasLength(candidateVersion)) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("No version found in path \"" + requestPath + "\"");
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class ServletUriComponentsBuilder extends UriComponentsBuilder {
|
||||
String forwardedPrefix = getForwardedPrefix(request);
|
||||
if (forwardedPrefix != null) {
|
||||
String contextPath = request.getContextPath();
|
||||
if (!StringUtils.isEmpty(contextPath) && !contextPath.equals("/") && path.startsWith(contextPath)) {
|
||||
if (StringUtils.hasLength(contextPath) && !contextPath.equals("/") && path.startsWith(contextPath)) {
|
||||
path = path.substring(contextPath.length());
|
||||
}
|
||||
path = forwardedPrefix + path;
|
||||
@@ -285,7 +285,7 @@ public class ServletUriComponentsBuilder extends UriComponentsBuilder {
|
||||
String extension = null;
|
||||
if (this.originalPath != null) {
|
||||
extension = UriUtils.extractFileExtension(this.originalPath);
|
||||
if (!StringUtils.isEmpty(extension)) {
|
||||
if (StringUtils.hasLength(extension)) {
|
||||
int end = this.originalPath.length() - (extension.length() + 1);
|
||||
replacePath(this.originalPath.substring(0, end));
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
return false;
|
||||
}
|
||||
String targetHost = UriComponentsBuilder.fromUriString(targetUrl).build().getHost();
|
||||
if (StringUtils.isEmpty(targetHost)) {
|
||||
if (!StringUtils.hasLength(targetHost)) {
|
||||
return false;
|
||||
}
|
||||
for (String host : getHosts()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -190,7 +190,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||
if (this.jsonpParameterNames != null) {
|
||||
for (String name : this.jsonpParameterNames) {
|
||||
String value = request.getParameter(name);
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
if (!StringUtils.hasLength(value)) {
|
||||
continue;
|
||||
}
|
||||
if (!isValidJsonpQueryParam(value)) {
|
||||
|
||||
Reference in New Issue
Block a user