Use consistent ternary expression style
Update all ternary expressions so that the condition is always in parentheses and "not equals" is used in the test. This helps to bring consistency across the codebase which makes ternary expression easier to scan. For example: `a = (a != null) ? a : b` Issue gh-8945
This commit is contained in:
@@ -128,7 +128,7 @@ public class AuthenticationPrincipalArgumentResolver implements HandlerMethodArg
|
||||
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));
|
||||
return (adapter != null) ? Mono.just(adapter.fromPublisher(principal)) : principal;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public class CurrentSecurityContextArgumentResolver implements HandlerMethodArgu
|
||||
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));
|
||||
return (adapter != null) ? Mono.just(adapter.fromPublisher(result)) : result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public final class SimpDestinationMessageMatcher implements MessageMatcher<Objec
|
||||
}
|
||||
|
||||
this.matcher = pathMatcher;
|
||||
this.messageTypeMatcher = type == null ? ANY_MESSAGE : new SimpMessageTypeMatcher(type);
|
||||
this.messageTypeMatcher = (type != null) ? new SimpMessageTypeMatcher(type) : ANY_MESSAGE;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public final class SimpDestinationMessageMatcher implements MessageMatcher<Objec
|
||||
|
||||
public Map<String, String> extractPathVariables(Message<?> message) {
|
||||
final String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
|
||||
return destination != null ? this.matcher.extractUriTemplateVariables(this.pattern, destination)
|
||||
return (destination != null) ? this.matcher.extractUriTemplateVariables(this.pattern, destination)
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ public final class CsrfChannelInterceptor extends ChannelInterceptorAdapter {
|
||||
}
|
||||
|
||||
Map<String, Object> sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(message.getHeaders());
|
||||
CsrfToken expectedToken = sessionAttributes == null ? null
|
||||
: (CsrfToken) sessionAttributes.get(CsrfToken.class.getName());
|
||||
CsrfToken expectedToken = (sessionAttributes != null)
|
||||
? (CsrfToken) sessionAttributes.get(CsrfToken.class.getName()) : null;
|
||||
|
||||
if (expectedToken == null) {
|
||||
throw new MissingCsrfTokenException(null);
|
||||
|
||||
@@ -220,10 +220,10 @@ public final class ResolvableMethod {
|
||||
|
||||
private String formatParameter(Parameter param) {
|
||||
Annotation[] anns = param.getAnnotations();
|
||||
return (anns.length > 0
|
||||
return (anns.length > 0)
|
||||
? Arrays.stream(anns).map(this::formatAnnotation).collect(Collectors.joining(",", "[", "]")) + " "
|
||||
+ param
|
||||
: param.toString());
|
||||
: param.toString();
|
||||
}
|
||||
|
||||
private String formatAnnotation(Annotation annotation) {
|
||||
@@ -591,9 +591,9 @@ 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));
|
||||
: param.getParameterAnnotations().length == 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user