1
0
mirror of synced 2026-05-22 13:23:17 +00:00

Use parenthesis with single-arg lambdas

Use regular expression search/replace to ensure all single-arg
lambdas have parenthesis. This aligns with the style used in Spring
Boot and ensure that single-arg and multi-arg lambdas are consistent.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-29 18:18:05 -07:00
committed by Rob Winch
parent 01d90c9881
commit 52f20b5281
426 changed files with 1668 additions and 1617 deletions
@@ -125,7 +125,7 @@ public class AuthenticationPrincipalArgumentResolver implements HandlerMethodArg
@Override
public Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) {
ReactiveAdapter adapter = this.adapterRegistry.getAdapter(parameter.getParameterType());
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication).flatMap(a -> {
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication).flatMap((a) -> {
Object p = resolvePrincipal(parameter, a.getPrincipal());
Mono<Object> principal = Mono.justOrEmpty(p);
return adapter == null ? principal : Mono.just(adapter.fromPublisher(principal));
@@ -124,7 +124,7 @@ public class CurrentSecurityContextArgumentResolver implements HandlerMethodArgu
@Override
public Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) {
ReactiveAdapter adapter = this.adapterRegistry.getAdapter(parameter.getParameterType());
return ReactiveSecurityContextHolder.getContext().flatMap(securityContext -> {
return ReactiveSecurityContextHolder.getContext().flatMap((securityContext) -> {
Object sc = resolveSecurityContext(parameter, securityContext);
Mono<Object> result = Mono.justOrEmpty(sc);
return adapter == null ? result : Mono.just(adapter.fromPublisher(result));
@@ -38,7 +38,7 @@ import org.springframework.util.PathMatcher;
*/
public final class SimpDestinationMessageMatcher implements MessageMatcher<Object> {
public static final MessageMatcher<Object> NULL_DESTINATION_MATCHER = message -> {
public static final MessageMatcher<Object> NULL_DESTINATION_MATCHER = (message) -> {
String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
return destination == null;
};
@@ -120,7 +120,7 @@ import org.springframework.util.ReflectionUtils;
* Locate a method by invoking it through a proxy of the target handler:
*
* <pre>
* ResolvableMethod.on(TestController.class).mockCall(o -> o.handle(null)).method();
* ResolvableMethod.on(TestController.class).mockCall((o) -> o.handle(null)).method();
* </pre>
*
* @author Rossen Stoyanchev
@@ -323,7 +323,7 @@ public final class ResolvableMethod {
* Filter on methods with the given name.
*/
public Builder<T> named(String methodName) {
addFilter("methodName=" + methodName, method -> method.getName().equals(methodName));
addFilter("methodName=" + methodName, (method) -> method.getName().equals(methodName));
return this;
}
@@ -331,7 +331,7 @@ public final class ResolvableMethod {
* Filter on methods with the given parameter types.
*/
public Builder<T> argTypes(Class<?>... argTypes) {
addFilter("argTypes=" + Arrays.toString(argTypes), method -> ObjectUtils.isEmpty(argTypes)
addFilter("argTypes=" + Arrays.toString(argTypes), (method) -> ObjectUtils.isEmpty(argTypes)
? method.getParameterCount() == 0 : Arrays.equals(method.getParameterTypes(), argTypes));
return this;
}
@@ -354,8 +354,8 @@ public final class ResolvableMethod {
@SafeVarargs
public final Builder<T> annotPresent(Class<? extends Annotation>... annotationTypes) {
String message = "annotationPresent=" + Arrays.toString(annotationTypes);
addFilter(message, candidate -> Arrays.stream(annotationTypes)
.allMatch(annotType -> AnnotatedElementUtils.findMergedAnnotation(candidate, annotType) != null));
addFilter(message, (candidate) -> Arrays.stream(annotationTypes)
.allMatch((annotType) -> AnnotatedElementUtils.findMergedAnnotation(candidate, annotType) != null));
return this;
}
@@ -365,10 +365,10 @@ public final class ResolvableMethod {
@SafeVarargs
public final Builder<T> annotNotPresent(Class<? extends Annotation>... annotationTypes) {
String message = "annotationNotPresent=" + Arrays.toString(annotationTypes);
addFilter(message, candidate -> {
addFilter(message, (candidate) -> {
if (annotationTypes.length != 0) {
return Arrays.stream(annotationTypes).noneMatch(
annotType -> AnnotatedElementUtils.findMergedAnnotation(candidate, annotType) != null);
(annotType) -> AnnotatedElementUtils.findMergedAnnotation(candidate, annotType) != null);
}
else {
return candidate.getAnnotations().length == 0;
@@ -403,7 +403,7 @@ public final class ResolvableMethod {
public Builder<T> returning(ResolvableType returnType) {
String expected = returnType.toString();
String message = "returnType=" + expected;
addFilter(message, m -> expected.equals(ResolvableType.forMethodReturnType(m).toString()));
addFilter(message, (m) -> expected.equals(ResolvableType.forMethodReturnType(m).toString()));
return this;
}
@@ -423,7 +423,7 @@ public final class ResolvableMethod {
}
private boolean isMatch(Method method) {
return this.filters.stream().allMatch(p -> p.test(method));
return this.filters.stream().allMatch((p) -> p.test(method));
}
private String formatMethods(Set<Method> methods) {
@@ -581,7 +581,7 @@ public final class ResolvableMethod {
*/
@SafeVarargs
public final ArgResolver annotPresent(Class<? extends Annotation>... annotationTypes) {
this.filters.add(param -> Arrays.stream(annotationTypes).allMatch(param::hasParameterAnnotation));
this.filters.add((param) -> Arrays.stream(annotationTypes).allMatch(param::hasParameterAnnotation));
return this;
}
@@ -591,7 +591,7 @@ public final class ResolvableMethod {
*/
@SafeVarargs
public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotationTypes) {
this.filters.add(param -> (annotationTypes.length > 0
this.filters.add((param) -> (annotationTypes.length > 0
? Arrays.stream(annotationTypes).noneMatch(param::hasParameterAnnotation)
: param.getParameterAnnotations().length == 0));
return this;
@@ -618,7 +618,7 @@ public final class ResolvableMethod {
* @param type the expected type
*/
public MethodParameter arg(ResolvableType type) {
this.filters.add(p -> type.toString().equals(ResolvableType.forMethodParameter(p).toString()));
this.filters.add((p) -> type.toString().equals(ResolvableType.forMethodParameter(p).toString()));
return arg();
}
@@ -638,7 +638,7 @@ public final class ResolvableMethod {
for (int i = 0; i < ResolvableMethod.this.method.getParameterCount(); i++) {
MethodParameter param = new SynthesizingMethodParameter(ResolvableMethod.this.method, i);
param.initParameterNameDiscovery(nameDiscoverer);
if (this.filters.stream().allMatch(p -> p.test(param))) {
if (this.filters.stream().allMatch((p) -> p.test(param))) {
matches.add(param);
}
}