Browse Source

Polish contribution

See gh-29994
pull/30047/head
Sam Brannen 2 years ago
parent
commit
9305a64a50
  1. 2
      spring-context/src/main/java/org/springframework/validation/ValidationUtils.java
  2. 4
      spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolver.java
  3. 6
      spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolver.java

2
spring-context/src/main/java/org/springframework/validation/ValidationUtils.java

@ -1,5 +1,5 @@ @@ -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.

4
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolver.java

@ -1,5 +1,5 @@ @@ -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 @@ -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);

6
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolver.java

@ -172,8 +172,8 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol @@ -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 @@ -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) {

Loading…
Cancel
Save