Browse Source

Apply project formatting rules for ternary operator

Discovered via RegEx: ^\s+\?
pull/29613/head
Sam Brannen 3 years ago
parent
commit
a88dbbec98
  1. 6
      spring-beans/src/main/java/org/springframework/beans/factory/aot/InstanceSupplierCodeGenerator.java
  2. 7
      spring-beans/src/test/java/org/springframework/beans/factory/aot/AotServicesTests.java
  3. 5
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
  4. 5
      spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java
  5. 5
      spring-core/src/main/java/org/springframework/aot/generate/DefaultMethodReference.java
  6. 4
      spring-core/src/main/java/org/springframework/aot/generate/MethodReference.java
  7. 5
      spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java
  8. 5
      spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java
  9. 5
      spring-core/src/main/java/org/springframework/core/io/support/PropertySourceProcessor.java
  10. 6
      spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java
  11. 6
      spring-jms/src/main/java/org/springframework/jms/listener/adapter/AbstractAdaptableMessageListener.java
  12. 4
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java

6
spring-beans/src/main/java/org/springframework/beans/factory/aot/InstanceSupplierCodeGenerator.java

@ -288,9 +288,9 @@ class InstanceSupplierCodeGenerator {
} }
private CodeBlock generateWithGeneratorCode(boolean hasArguments, CodeBlock newInstance) { private CodeBlock generateWithGeneratorCode(boolean hasArguments, CodeBlock newInstance) {
CodeBlock lambdaArguments = (hasArguments CodeBlock lambdaArguments = (hasArguments ?
? CodeBlock.of("($L, $L)", REGISTERED_BEAN_PARAMETER_NAME, ARGS_PARAMETER_NAME) CodeBlock.of("($L, $L)", REGISTERED_BEAN_PARAMETER_NAME, ARGS_PARAMETER_NAME) :
: CodeBlock.of("($L)", REGISTERED_BEAN_PARAMETER_NAME)); CodeBlock.of("($L)", REGISTERED_BEAN_PARAMETER_NAME));
Builder code = CodeBlock.builder(); Builder code = CodeBlock.builder();
code.add("\n"); code.add("\n");
code.indent().indent(); code.indent().indent();

7
spring-beans/src/test/java/org/springframework/beans/factory/aot/AotServicesTests.java

@ -238,10 +238,9 @@ class AotServicesTests {
@Override @Override
public Enumeration<URL> getResources(String name) throws IOException { public Enumeration<URL> getResources(String name) throws IOException {
return (!"META-INF/spring/aot.factories".equals(name)) return (!"META-INF/spring/aot.factories".equals(name) ?
? super.getResources(name) super.getResources(name) :
: super.getResources("org/springframework/beans/factory/aot/" super.getResources("org/springframework/beans/factory/aot/" + this.factoriesName));
+ this.factoriesName);
} }
} }

5
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

@ -147,9 +147,8 @@ class ConfigurationClassParser {
this.problemReporter = problemReporter; this.problemReporter = problemReporter;
this.environment = environment; this.environment = environment;
this.resourceLoader = resourceLoader; this.resourceLoader = resourceLoader;
this.propertySourceRegistry = (this.environment instanceof ConfigurableEnvironment ce this.propertySourceRegistry = (this.environment instanceof ConfigurableEnvironment ce ?
? new PropertySourceRegistry(new PropertySourceProcessor(ce, this.resourceLoader)) new PropertySourceRegistry(new PropertySourceProcessor(ce, this.resourceLoader)) : null);
: null);
this.registry = registry; this.registry = registry;
this.componentScanParser = new ComponentScanAnnotationParser( this.componentScanParser = new ComponentScanAnnotationParser(
environment, resourceLoader, componentScanBeanNameGenerator, registry); environment, resourceLoader, componentScanBeanNameGenerator, registry);

5
spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java

@ -180,9 +180,8 @@ public final class SourceFile extends DynamicFile implements AssertProvider<Sour
} }
Assert.state(javaSource.getClasses().size() == 1, "Source must define a single class"); Assert.state(javaSource.getClasses().size() == 1, "Source must define a single class");
JavaClass javaClass = javaSource.getClasses().get(0); JavaClass javaClass = javaSource.getClasses().get(0);
return (javaSource.getPackage() != null) return (javaSource.getPackage() != null) ?
? javaSource.getPackageName() + "." + javaClass.getName() (javaSource.getPackageName() + "." + javaClass.getName()) : javaClass.getName();
: javaClass.getName();
} }
catch (Exception ex) { catch (Exception ex) {
throw new IllegalStateException( throw new IllegalStateException(

5
spring-core/src/main/java/org/springframework/aot/generate/DefaultMethodReference.java

@ -128,9 +128,8 @@ public class DefaultMethodReference implements MethodReference {
return this.declaringClass + "::" + methodName; return this.declaringClass + "::" + methodName;
} }
else { else {
return ((this.declaringClass != null) return ((this.declaringClass != null) ?
? "<" + this.declaringClass + ">" : "<instance>") "<" + this.declaringClass + ">" : "<instance>") + "::" + methodName;
+ "::" + methodName;
} }
} }

4
spring-core/src/main/java/org/springframework/aot/generate/MethodReference.java

@ -94,8 +94,8 @@ public interface MethodReference {
* @return a new {@link ArgumentCodeGenerator} instance * @return a new {@link ArgumentCodeGenerator} instance
*/ */
static ArgumentCodeGenerator of(Class<?> argumentType, String argumentCode) { static ArgumentCodeGenerator of(Class<?> argumentType, String argumentCode) {
return from(candidateType -> (candidateType.equals(ClassName.get(argumentType)) return from(candidateType -> candidateType.equals(ClassName.get(argumentType)) ?
? CodeBlock.of(argumentCode) : null)); CodeBlock.of(argumentCode) : null);
} }
/** /**

5
spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java

@ -47,9 +47,8 @@ public abstract class AbstractTypeReference implements TypeReference {
public String getName() { public String getName() {
TypeReference enclosingType = getEnclosingType(); TypeReference enclosingType = getEnclosingType();
String simpleName = getSimpleName(); String simpleName = getSimpleName();
return (enclosingType != null return (enclosingType != null ? (enclosingType.getName() + '$' + simpleName) :
? (enclosingType.getName() + '$' + simpleName) addPackageIfNecessary(simpleName));
: addPackageIfNecessary(simpleName));
} }
@Override @Override

5
spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java

@ -35,9 +35,8 @@ final class ReflectionTypeReference extends AbstractTypeReference {
@Nullable @Nullable
private static TypeReference getEnclosingClass(Class<?> type) { private static TypeReference getEnclosingClass(Class<?> type) {
Class<?> candidate = (type.isArray() Class<?> candidate = (type.isArray() ? type.getComponentType().getEnclosingClass() :
? type.getComponentType().getEnclosingClass() type.getEnclosingClass());
: type.getEnclosingClass());
return (candidate != null ? new ReflectionTypeReference(candidate) : null); return (candidate != null ? new ReflectionTypeReference(candidate) : null);
} }

5
spring-core/src/main/java/org/springframework/core/io/support/PropertySourceProcessor.java

@ -77,9 +77,8 @@ public class PropertySourceProcessor {
List<String> locations = descriptor.locations(); List<String> locations = descriptor.locations();
Assert.isTrue(locations.size() > 0, "At least one @PropertySource(value) location is required"); Assert.isTrue(locations.size() > 0, "At least one @PropertySource(value) location is required");
boolean ignoreResourceNotFound = descriptor.ignoreResourceNotFound(); boolean ignoreResourceNotFound = descriptor.ignoreResourceNotFound();
PropertySourceFactory factory = (descriptor.propertySourceFactory() != null PropertySourceFactory factory = (descriptor.propertySourceFactory() != null ?
? instantiateClass(descriptor.propertySourceFactory()) instantiateClass(descriptor.propertySourceFactory()) : DEFAULT_PROPERTY_SOURCE_FACTORY);
: DEFAULT_PROPERTY_SOURCE_FACTORY);
for (String location : locations) { for (String location : locations) {
try { try {

6
spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -180,9 +180,7 @@ class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
methods.add(method); methods.add(method);
} }
}); });
Method bridgeMethod = methods.get(0).getReturnType().equals(Object.class) Method bridgeMethod = methods.get(0).getReturnType() == Object.class ? methods.get(0) : methods.get(1);
? methods.get(0)
: methods.get(1);
assertThat(bridgeMethod.isBridge()).isTrue(); assertThat(bridgeMethod.isBridge()).isTrue();
return bridgeMethod; return bridgeMethod;
} }

6
spring-jms/src/main/java/org/springframework/jms/listener/adapter/AbstractAdaptableMessageListener.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -303,8 +303,8 @@ public abstract class AbstractAdaptableMessageListener
* @see #setMessageConverter * @see #setMessageConverter
*/ */
protected Message buildMessage(Session session, Object result) throws JMSException { protected Message buildMessage(Session session, Object result) throws JMSException {
Object content = preProcessResponse(result instanceof JmsResponse Object content = preProcessResponse(result instanceof JmsResponse<?> jmsResponse ?
? ((JmsResponse<?>) result).getResponse() : result); jmsResponse.getResponse() : result);
MessageConverter converter = getMessageConverter(); MessageConverter converter = getMessageConverter();
if (converter != null) { if (converter != null) {

4
spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java

@ -170,8 +170,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
assertTargetBean(getBridgedMethod(), getBean(), args); assertTargetBean(getBridgedMethod(), getBean(), args);
String text = (ex.getMessage() == null || ex.getCause() instanceof NullPointerException) String text = (ex.getMessage() == null || ex.getCause() instanceof NullPointerException) ?
? "Illegal argument": ex.getMessage(); "Illegal argument": ex.getMessage();
throw new IllegalStateException(formatInvokeError(text, args), ex); throw new IllegalStateException(formatInvokeError(text, args), ex);
} }
catch (InvocationTargetException ex) { catch (InvocationTargetException ex) {

Loading…
Cancel
Save