Polish contribution

See gh-29994
This commit is contained in:
Sam Brannen 2023-02-26 18:22:50 +01:00
parent 40672c3715
commit 9305a64a50
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2023 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@ -290,7 +290,7 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol
Validated validatedAnn = AnnotationUtils.getAnnotation(ann, Validated.class);
if (validatedAnn != null || ann.annotationType().getSimpleName().startsWith("Valid")) {
Object hints = (validatedAnn != null ? validatedAnn.value() : AnnotationUtils.getValue(ann));
Object[] validationHints = (hints instanceof Object[] objectHint ? objectHint : new Object[] {hints});
Object[] validationHints = (hints instanceof Object[] objectHints ? objectHints : new Object[] {hints});
String name = Conventions.getVariableNameForParameter(parameter);
return target -> {
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(target, name);

View File

@ -172,8 +172,8 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol
else if (payload instanceof byte[] bytes) {
return bytes.length == 0;
}
else if (payload instanceof String s) {
return !StringUtils.hasText(s);
else if (payload instanceof String text) {
return !StringUtils.hasText(text);
}
else if (payload instanceof Optional<?> optional) {
return optional.isEmpty();
@ -216,7 +216,7 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol
Validated validatedAnn = AnnotationUtils.getAnnotation(ann, Validated.class);
if (validatedAnn != null || ann.annotationType().getSimpleName().startsWith("Valid")) {
Object hints = (validatedAnn != null ? validatedAnn.value() : AnnotationUtils.getValue(ann));
Object[] validationHints = (hints instanceof Object[] objectHint ? objectHint : new Object[] {hints});
Object[] validationHints = (hints instanceof Object[] objectHints ? objectHints : new Object[] {hints});
BeanPropertyBindingResult bindingResult =
new BeanPropertyBindingResult(target, getParameterName(parameter));
if (!ObjectUtils.isEmpty(validationHints) && this.validator instanceof SmartValidator sv) {