Skip to content

Commit 0f4205a

Browse files
committed
Polish assertions
1 parent 93b340e commit 0f4205a

16 files changed

+61
-61
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class AotFactoriesLoader {
5858
* @param beanFactory the bean factory to use
5959
*/
6060
public AotFactoriesLoader(ListableBeanFactory beanFactory) {
61-
Assert.notNull(beanFactory, "BeanFactory must not be null");
61+
Assert.notNull(beanFactory, "'beanFactory' must not be null");
6262
ClassLoader classLoader = (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory)
6363
? configurableBeanFactory.getBeanClassLoader() : null;
6464
this.beanFactory = beanFactory;
@@ -76,8 +76,8 @@ public AotFactoriesLoader(ListableBeanFactory beanFactory) {
7676
public AotFactoriesLoader(ListableBeanFactory beanFactory,
7777
SpringFactoriesLoader factoriesLoader) {
7878

79-
Assert.notNull(beanFactory, "BeanFactory must not be null");
80-
Assert.notNull(factoriesLoader, "FactoriesLoader must not be null");
79+
Assert.notNull(beanFactory, "'beanFactory' must not be null");
80+
Assert.notNull(factoriesLoader, "'factoriesLoader' must not be null");
8181
this.beanFactory = beanFactory;
8282
this.factoriesLoader = factoriesLoader;
8383
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ default Object getObject(int index) {
8080
* @return a new {@link AutowiredArguments} instance
8181
*/
8282
static AutowiredArguments of(Object[] arguments) {
83-
Assert.notNull(arguments, "Arguments must not be null");
83+
Assert.notNull(arguments, "'arguments' must not be null");
8484
return () -> arguments;
8585
}
8686

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public CodeBlock generateCode(Class<?>[] parameterTypes, int startIndex) {
6666
public CodeBlock generateCode(Class<?>[] parameterTypes, int startIndex,
6767
String variableName) {
6868

69-
Assert.notNull(parameterTypes, "ParameterTypes must not be null");
70-
Assert.notNull(variableName, "VariableName must not be null");
69+
Assert.notNull(parameterTypes, "'parameterTypes' must not be null");
70+
Assert.notNull(variableName, "'variableName' must not be null");
7171
boolean ambiguous = isAmbiguous();
7272
CodeBlock.Builder builder = CodeBlock.builder();
7373
for (int i = startIndex; i < parameterTypes.length; i++) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver
6464
private AutowiredFieldValueResolver(String fieldName, boolean required,
6565
@Nullable String shortcut) {
6666

67-
Assert.hasText(fieldName, "FieldName must not be empty");
67+
Assert.hasText(fieldName, "'fieldName' must not be empty");
6868
this.fieldName = fieldName;
6969
this.required = required;
7070
this.shortcut = shortcut;
@@ -110,8 +110,8 @@ public AutowiredFieldValueResolver withShortcut(String beanName) {
110110
* @param action the action to execute with the resolved field value
111111
*/
112112
public <T> void resolve(RegisteredBean registeredBean, ThrowingConsumer<T> action) {
113-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
114-
Assert.notNull(action, "Action must not be null");
113+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
114+
Assert.notNull(action, "'action' must not be null");
115115
T resolved = resolve(registeredBean);
116116
if (resolved != null) {
117117
action.accept(resolved);
@@ -150,7 +150,7 @@ public <T> T resolve(RegisteredBean registeredBean) {
150150
*/
151151
@Nullable
152152
public Object resolveObject(RegisteredBean registeredBean) {
153-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
153+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
154154
return resolveValue(registeredBean, getField(registeredBean));
155155
}
156156

@@ -161,8 +161,8 @@ public Object resolveObject(RegisteredBean registeredBean) {
161161
* @param instance the bean instance
162162
*/
163163
public void resolveAndSet(RegisteredBean registeredBean, Object instance) {
164-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
165-
Assert.notNull(instance, "Instance must not be null");
164+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
165+
Assert.notNull(instance, "'instance' must not be null");
166166
Field field = getField(registeredBean);
167167
Object resolved = resolveValue(registeredBean, field);
168168
if (resolved != null) {

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ private AutowiredInstantiationArgumentsResolver(ExecutableLookup lookup,
9494
public static AutowiredInstantiationArgumentsResolver forConstructor(
9595
Class<?>... parameterTypes) {
9696

97-
Assert.notNull(parameterTypes, "ParameterTypes must not be null");
97+
Assert.notNull(parameterTypes, "'parameterTypes' must not be null");
9898
Assert.noNullElements(parameterTypes,
99-
"ParameterTypes must not contain null elements");
99+
"'parameterTypes' must not contain null elements");
100100
return new AutowiredInstantiationArgumentsResolver(
101101
new ConstructorLookup(parameterTypes), null);
102102
}
@@ -112,11 +112,11 @@ public static AutowiredInstantiationArgumentsResolver forConstructor(
112112
public static AutowiredInstantiationArgumentsResolver forFactoryMethod(
113113
Class<?> declaringClass, String methodName, Class<?>... parameterTypes) {
114114

115-
Assert.notNull(declaringClass, "DeclaringClass must not be null");
116-
Assert.hasText(methodName, "MethodName must not be empty");
117-
Assert.notNull(parameterTypes, "ParameterTypes must not be null");
115+
Assert.notNull(declaringClass, "'declaringClass' must not be null");
116+
Assert.hasText(methodName, "'methodName' must not be empty");
117+
Assert.notNull(parameterTypes, "'parameterTypes' must not be null");
118118
Assert.noNullElements(parameterTypes,
119-
"ParameterTypes must not contain null elements");
119+
"'parameterTypes' must not contain null elements");
120120
return new AutowiredInstantiationArgumentsResolver(
121121
new FactoryMethodLookup(declaringClass, methodName, parameterTypes),
122122
null);
@@ -149,8 +149,8 @@ public AutowiredInstantiationArgumentsResolver withShortcuts(String... beanNames
149149
public <T> T resolve(RegisteredBean registeredBean,
150150
ThrowingFunction<AutowiredArguments, T> generator) {
151151

152-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
153-
Assert.notNull(generator, "Action must not be null");
152+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
153+
Assert.notNull(generator, "'action' must not be null");
154154
AutowiredArguments resolved = resolveArguments(registeredBean,
155155
this.lookup.get(registeredBean));
156156
return generator.apply(resolved);
@@ -162,7 +162,7 @@ public <T> T resolve(RegisteredBean registeredBean,
162162
* @return the resolved constructor or factory method arguments
163163
*/
164164
public AutowiredArguments resolve(RegisteredBean registeredBean) {
165-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
165+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
166166
return resolveArguments(registeredBean, this.lookup.get(registeredBean));
167167
}
168168

@@ -188,8 +188,8 @@ public <T> T resolveAndInstantiate(RegisteredBean registeredBean) {
188188
public <T> T resolveAndInstantiate(RegisteredBean registeredBean,
189189
Class<T> requiredType) {
190190

191-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
192-
Assert.notNull(registeredBean, "RequiredType must not be null");
191+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
192+
Assert.notNull(registeredBean, "'requiredType' must not be null");
193193
Executable executable = this.lookup.get(registeredBean);
194194
AutowiredArguments arguments = resolveArguments(registeredBean, executable);
195195
Object instance = instantiate(registeredBean.getBeanFactory(), executable,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso
6969
private AutowiredMethodArgumentsResolver(String methodName, Class<?>[] parameterTypes,
7070
boolean required, @Nullable String[] shortcuts) {
7171

72-
Assert.hasText(methodName, "MethodName must not be empty");
72+
Assert.hasText(methodName, "'methodName' must not be empty");
7373
this.methodName = methodName;
7474
this.parameterTypes = parameterTypes;
7575
this.required = required;
@@ -126,8 +126,8 @@ public AutowiredMethodArgumentsResolver withShortcut(String... beanNames) {
126126
public void resolve(RegisteredBean registeredBean,
127127
ThrowingConsumer<AutowiredArguments> action) {
128128

129-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
130-
Assert.notNull(action, "Action must not be null");
129+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
130+
Assert.notNull(action, "'action' must not be null");
131131
AutowiredArguments resolved = resolve(registeredBean);
132132
if (resolved != null) {
133133
action.accept(resolved);
@@ -141,7 +141,7 @@ public void resolve(RegisteredBean registeredBean,
141141
*/
142142
@Nullable
143143
public AutowiredArguments resolve(RegisteredBean registeredBean) {
144-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
144+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
145145
return resolveArguments(registeredBean, getMethod(registeredBean));
146146
}
147147

@@ -152,8 +152,8 @@ public AutowiredArguments resolve(RegisteredBean registeredBean) {
152152
* @param instance the bean instance
153153
*/
154154
public void resolveAndInvoke(RegisteredBean registeredBean, Object instance) {
155-
Assert.notNull(registeredBean, "RegisteredBean must not be null");
156-
Assert.notNull(instance, "Instance must not be null");
155+
Assert.notNull(registeredBean, "'registeredBean' must not be null");
156+
Assert.notNull(instance, "'instance' must not be null");
157157
Method method = getMethod(registeredBean);
158158
AutowiredArguments resolved = resolveArguments(registeredBean, method);
159159
if (resolved != null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public abstract class BeanRegistrationCodeFragments {
5353

5454

5555
protected BeanRegistrationCodeFragments(BeanRegistrationCodeFragments codeFragments) {
56-
Assert.notNull(codeFragments, "CodeFragments must not be null");
56+
Assert.notNull(codeFragments, "'codeFragments' must not be null");
5757
this.codeFragments = codeFragments;
5858
}
5959

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public MethodGenerator getMethodGenerator() {
7575

7676
@Override
7777
public void addInstancePostProcessor(MethodReference methodReference) {
78-
Assert.notNull(methodReference, "MethodReference must not be null");
78+
Assert.notNull(methodReference, "'methodReference' must not be null");
7979
this.instancePostProcessors.add(methodReference);
8080
}
8181

spring-beans/src/main/java/org/springframework/beans/factory/support/RegisteredBean.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ private RegisteredBean(ConfigurableBeanFactory beanFactory, Supplier<String> bea
7474
public static RegisteredBean of(ConfigurableBeanFactory beanFactory,
7575
String beanName) {
7676

77-
Assert.notNull(beanFactory, "BeanFactory must not be null");
78-
Assert.hasLength(beanName, "BeanName must not be empty");
77+
Assert.notNull(beanFactory, "'beanFactory' must not be null");
78+
Assert.hasLength(beanName, "'beanName' must not be empty");
7979
return new RegisteredBean(beanFactory, () -> beanName, false,
8080
() -> (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName),
8181
null);
@@ -90,7 +90,7 @@ public static RegisteredBean of(ConfigurableBeanFactory beanFactory,
9090
public static RegisteredBean ofInnerBean(RegisteredBean parent,
9191
BeanDefinitionHolder innerBean) {
9292

93-
Assert.notNull(innerBean, "InnerBean must not be null");
93+
Assert.notNull(innerBean, "'innerBean' must not be null");
9494
return ofInnerBean(parent, innerBean.getBeanName(),
9595
innerBean.getBeanDefinition());
9696
}
@@ -118,8 +118,8 @@ public static RegisteredBean ofInnerBean(RegisteredBean parent,
118118
public static RegisteredBean ofInnerBean(RegisteredBean parent,
119119
@Nullable String innerBeanName, BeanDefinition innerBeanDefinition) {
120120

121-
Assert.notNull(parent, "Parent must not be null");
122-
Assert.notNull(innerBeanDefinition, "InnerBeanDefinition must not be null");
121+
Assert.notNull(parent, "'parent' must not be null");
122+
Assert.notNull(innerBeanDefinition, "'innerBeanDefinition' must not be null");
123123
InnerBeanResolver resolver = new InnerBeanResolver(parent, innerBeanName,
124124
innerBeanDefinition);
125125
Supplier<String> beanName = StringUtils.hasLength(innerBeanName)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ class AotFactoriesLoaderTests {
3939
void createWhenBeanFactoryIsNullThrowsException() {
4040
assertThatIllegalArgumentException()
4141
.isThrownBy(() -> new AotFactoriesLoader(null))
42-
.withMessage("BeanFactory must not be null");
42+
.withMessage("'beanFactory' must not be null");
4343
}
4444

4545
@Test
4646
void createWhenSpringFactoriesLoaderIsNullThrowsException() {
4747
ListableBeanFactory beanFactory = new DefaultListableBeanFactory();
4848
assertThatIllegalArgumentException()
4949
.isThrownBy(() -> new AotFactoriesLoader(beanFactory, null))
50-
.withMessage("FactoriesLoader must not be null");
50+
.withMessage("'factoriesLoader' must not be null");
5151
}
5252

5353
@Test

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AutowiredFieldValueResolverTests {
4545

4646
@Test
4747
void forFieldWhenFieldNameIsEmptyThrowsException() {
48-
String message = "FieldName must not be empty";
48+
String message = "'fieldName' must not be empty";
4949
assertThatIllegalArgumentException()
5050
.isThrownBy(() -> AutowiredFieldValueResolver.forField(null))
5151
.withMessage(message);
@@ -64,7 +64,7 @@ void forFieldWhenFieldNameIsEmptyThrowsException() {
6464
void resolveWhenRegisteredBeanIsNullThrowsException() {
6565
assertThatIllegalArgumentException().isThrownBy(
6666
() -> AutowiredFieldValueResolver.forField("string").resolve(null))
67-
.withMessage("RegisteredBean must not be null");
67+
.withMessage("'registeredBean' must not be null");
6868
}
6969

7070
@Test
@@ -122,7 +122,7 @@ void resolveAndSetWhenInstanceIsNullThrowsException() {
122122
assertThatIllegalArgumentException()
123123
.isThrownBy(() -> AutowiredFieldValueResolver.forField("string")
124124
.resolveAndSet(registeredBean, null))
125-
.withMessage("Instance must not be null");
125+
.withMessage("'instance' must not be null");
126126
}
127127

128128
@Test
@@ -141,7 +141,7 @@ void resolveWithActionWhenActionIsNullThrowsException() {
141141
assertThatIllegalArgumentException()
142142
.isThrownBy(() -> AutowiredFieldValueResolver.forField("string")
143143
.resolve(registeredBean, (ThrowingConsumer<Object>) null))
144-
.withMessage("Action must not be null");
144+
.withMessage("'action' must not be null");
145145
}
146146

147147
@Test

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ void forConstructorWhenParameterTypesIsNullThrowsException() {
7676
assertThatIllegalArgumentException()
7777
.isThrownBy(() -> AutowiredInstantiationArgumentsResolver
7878
.forConstructor((Class<?>[]) null))
79-
.withMessage("ParameterTypes must not be null");
79+
.withMessage("'parameterTypes' must not be null");
8080
}
8181

8282
@Test
8383
void forConstructorWhenParameterTypesContainsNullThrowsException() {
8484
assertThatIllegalArgumentException()
8585
.isThrownBy(() -> AutowiredInstantiationArgumentsResolver
8686
.forConstructor(String.class, null))
87-
.withMessage("ParameterTypes must not contain null elements");
87+
.withMessage("'parameterTypes' must not contain null elements");
8888
}
8989

9090
@Test
@@ -104,15 +104,15 @@ void forFactoryMethodWhenDeclaringClassIsNullThrowsException() {
104104
assertThatIllegalArgumentException()
105105
.isThrownBy(() -> AutowiredInstantiationArgumentsResolver
106106
.forFactoryMethod(null, "test"))
107-
.withMessage("DeclaringClass must not be null");
107+
.withMessage("'declaringClass' must not be null");
108108
}
109109

110110
@Test
111111
void forFactoryMethodWhenNameIsEmptyThrowsException() {
112112
assertThatIllegalArgumentException()
113113
.isThrownBy(() -> AutowiredInstantiationArgumentsResolver
114114
.forFactoryMethod(SingleArgFactory.class, ""))
115-
.withMessage("MethodName must not be empty");
115+
.withMessage("'methodName' must not be empty");
116116
}
117117

118118
@Test
@@ -121,7 +121,7 @@ void forFactoryMethodWhenParameterTypesIsNullThrowsException() {
121121
.isThrownBy(
122122
() -> AutowiredInstantiationArgumentsResolver.forFactoryMethod(
123123
SingleArgFactory.class, "single", (Class<?>[]) null))
124-
.withMessage("ParameterTypes must not be null");
124+
.withMessage("'parameterTypes' must not be null");
125125
}
126126

127127
@Test
@@ -130,7 +130,7 @@ void forFactoryMethodWhenParameterTypesContainsNullThrowsException() {
130130
.isThrownBy(
131131
() -> AutowiredInstantiationArgumentsResolver.forFactoryMethod(
132132
SingleArgFactory.class, "single", String.class, null))
133-
.withMessage("ParameterTypes must not contain null elements");
133+
.withMessage("'parameterTypes' must not contain null elements");
134134
}
135135

136136
@Test
@@ -153,7 +153,7 @@ void resolveWithActionWhenActionIsNullThrowsException() {
153153
RegisteredBean registerBean = source.registerBean(this.beanFactory);
154154
assertThatIllegalArgumentException()
155155
.isThrownBy(() -> resolver.resolve(registerBean, null))
156-
.withMessage("Action must not be null");
156+
.withMessage("'action' must not be null");
157157
}
158158

159159
@Test
@@ -174,7 +174,7 @@ void resolveWhenRegisteredBeanIsNullThrowsException() {
174174
AutowiredInstantiationArgumentsResolver resolver = AutowiredInstantiationArgumentsResolver
175175
.forConstructor(String.class);
176176
assertThatIllegalArgumentException().isThrownBy(() -> resolver.resolve(null))
177-
.withMessage("RegisteredBean must not be null");
177+
.withMessage("'registeredBean' must not be null");
178178
}
179179

180180
@ParameterizedResolverTest(Sources.SINGLE_ARG)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AutowiredMethodArgumentsResolverTests {
4747

4848
@Test
4949
void forMethodWhenMethodNameIsEmptyThrowsException() {
50-
String message = "MethodName must not be empty";
50+
String message = "'methodName' must not be empty";
5151
assertThatIllegalArgumentException()
5252
.isThrownBy(() -> AutowiredMethodArgumentsResolver.forMethod(null))
5353
.withMessage(message);
@@ -68,7 +68,7 @@ void resolveWhenRegisteredBeanIsNullThrowsException() {
6868
assertThatIllegalArgumentException()
6969
.isThrownBy(() -> AutowiredMethodArgumentsResolver
7070
.forMethod("injectString", String.class).resolve(null))
71-
.withMessage("RegisteredBean must not be null");
71+
.withMessage("'registeredBean' must not be null");
7272
}
7373

7474
@Test
@@ -134,7 +134,7 @@ void resolveAndInvokeWhenInstanceIsNullThrowsException() {
134134
.isThrownBy(() -> AutowiredMethodArgumentsResolver
135135
.forMethod("injectString", String.class)
136136
.resolveAndInvoke(registeredBean, null))
137-
.withMessage("Instance must not be null");
137+
.withMessage("'instance' must not be null");
138138
}
139139

140140
@Test
@@ -155,7 +155,7 @@ void resolveWithActionWhenActionIsNullThrowsException() {
155155
.isThrownBy(() -> AutowiredMethodArgumentsResolver
156156
.forMethod("injectString", String.class)
157157
.resolve(registeredBean, null))
158-
.withMessage("Action must not be null");
158+
.withMessage("'action' must not be null");
159159
}
160160

161161
@Test

0 commit comments

Comments
 (0)