Skip to content

Commit 2aa7888

Browse files
committed
Use consistent wording in precondition error messages
1 parent 711a63a commit 2aa7888

File tree

27 files changed

+88
-86
lines changed

27 files changed

+88
-86
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ public RuntimeBeanReference(Class<?> beanType) {
8282
* @since 5.2
8383
*/
8484
public RuntimeBeanReference(Class<?> beanType, boolean toParent) {
85-
Assert.notNull(beanType, "'beanType' must not be empty");
85+
Assert.notNull(beanType, "'beanType' must not be null");
8686
this.beanName = beanType.getName();
8787
this.beanType = beanType;
8888
this.toParent = toParent;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ public Scope getRegisteredScope(String scopeName) {
10541054

10551055
@Override
10561056
public void setApplicationStartup(ApplicationStartup applicationStartup) {
1057-
Assert.notNull(applicationStartup, "applicationStartup should not be null");
1057+
Assert.notNull(applicationStartup, "applicationStartup must not be null");
10581058
this.applicationStartup = applicationStartup;
10591059
}
10601060

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalState
439439

440440
@Override
441441
public void setApplicationStartup(ApplicationStartup applicationStartup) {
442-
Assert.notNull(applicationStartup, "applicationStartup should not be null");
442+
Assert.notNull(applicationStartup, "applicationStartup must not be null");
443443
this.applicationStartup = applicationStartup;
444444
}
445445

spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public ScheduledAnnotationBeanPostProcessor() {
159159
* @since 5.1
160160
*/
161161
public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar) {
162-
Assert.notNull(registrar, "ScheduledTaskRegistrar is required");
162+
Assert.notNull(registrar, "ScheduledTaskRegistrar must not be null");
163163
this.registrar = registrar;
164164
}
165165

spring-core-test/src/main/java/org/springframework/aot/agent/InvocationsRecorderClassTransformer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class InvocationsRecorderClassTransformer implements ClassFileTransformer {
4444
private final String[] ignoredPackages;
4545

4646
public InvocationsRecorderClassTransformer(String[] instrumentedPackages, String[] ignoredPackages) {
47-
Assert.notNull(instrumentedPackages, "instrumentedPackages should not be null");
48-
Assert.notNull(ignoredPackages, "ignoredPackages should not be null");
47+
Assert.notNull(instrumentedPackages, "instrumentedPackages must not be null");
48+
Assert.notNull(ignoredPackages, "ignoredPackages must not be null");
4949
this.instrumentedPackages = rewriteToAsmFormat(instrumentedPackages);
5050
this.ignoredPackages = rewriteToAsmFormat(ignoredPackages);
5151
}

spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsInvocationsAssert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private void configureRuntimeHints(RuntimeHints hints) {
7474
* @throws AssertionError if any of the recorded invocations has no match in the provided hints
7575
*/
7676
public void match(RuntimeHints runtimeHints) {
77-
Assert.notNull(runtimeHints, "RuntimeHints should not be null");
77+
Assert.notNull(runtimeHints, "RuntimeHints must not be null");
7878
configureRuntimeHints(runtimeHints);
7979
List<RecordedInvocation> noMatchInvocations =
8080
this.actual.recordedInvocations().filter(invocation -> !invocation.matches(runtimeHints)).toList();
@@ -84,7 +84,7 @@ public void match(RuntimeHints runtimeHints) {
8484
}
8585

8686
public ListAssert<RecordedInvocation> notMatching(RuntimeHints runtimeHints) {
87-
Assert.notNull(runtimeHints, "RuntimeHints should not be null");
87+
Assert.notNull(runtimeHints, "RuntimeHints must not be null");
8888
configureRuntimeHints(runtimeHints);
8989
return ListAssert.assertThatStream(this.actual.recordedInvocations()
9090
.filter(invocation -> !invocation.matches(runtimeHints)));

spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private RuntimeHintsRecorder() {
4848
* @return the recorded invocations
4949
*/
5050
public synchronized static RuntimeHintsInvocations record(Runnable action) {
51-
Assert.notNull(action, "Runnable action should not be null");
51+
Assert.notNull(action, "Runnable action must not be null");
5252
Assert.isTrue(RuntimeHintsAgent.isLoaded(), "RuntimeHintsAgent should be loaded in the current JVM");
5353
RuntimeHintsRecorder recorder = new RuntimeHintsRecorder();
5454
RecordedInvocationsPublisher.addListener(recorder.listener);

spring-core/src/main/java/org/springframework/aot/hint/predicate/ReflectionHintsPredicates.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ public class ReflectionHintsPredicates {
5151
ReflectionHintsPredicates() {
5252
}
5353

54+
5455
/**
5556
* Return a predicate that checks whether a reflection hint is registered for the given type.
5657
* <p>The returned type exposes additional methods that refine the predicate behavior.
5758
* @param typeReference the type
5859
* @return the {@link RuntimeHints} predicate
5960
*/
6061
public TypeHintPredicate onType(TypeReference typeReference) {
61-
Assert.notNull(typeReference, "'typeReference' should not be null");
62+
Assert.notNull(typeReference, "'typeReference' must not be null");
6263
return new TypeHintPredicate(typeReference);
6364
}
6465

@@ -69,7 +70,7 @@ public TypeHintPredicate onType(TypeReference typeReference) {
6970
* @return the {@link RuntimeHints} predicate
7071
*/
7172
public TypeHintPredicate onType(Class<?> type) {
72-
Assert.notNull(type, "'type' should not be null");
73+
Assert.notNull(type, "'type' must not be null");
7374
return new TypeHintPredicate(TypeReference.of(type));
7475
}
7576

@@ -81,7 +82,7 @@ public TypeHintPredicate onType(Class<?> type) {
8182
* @return the {@link RuntimeHints} predicate
8283
*/
8384
public ConstructorHintPredicate onConstructor(Constructor<?> constructor) {
84-
Assert.notNull(constructor, "'constructor' should not be null");
85+
Assert.notNull(constructor, "'constructor' must not be null");
8586
return new ConstructorHintPredicate(constructor);
8687
}
8788

@@ -93,7 +94,7 @@ public ConstructorHintPredicate onConstructor(Constructor<?> constructor) {
9394
* @return the {@link RuntimeHints} predicate
9495
*/
9596
public MethodHintPredicate onMethod(Method method) {
96-
Assert.notNull(method, "'method' should not be null");
97+
Assert.notNull(method, "'method' must not be null");
9798
return new MethodHintPredicate(method);
9899
}
99100

@@ -108,8 +109,8 @@ public MethodHintPredicate onMethod(Method method) {
108109
* @throws IllegalArgumentException if the method cannot be found or if multiple methods are found with the same name.
109110
*/
110111
public MethodHintPredicate onMethod(Class<?> type, String methodName) {
111-
Assert.notNull(type, "'type' should not be null");
112-
Assert.hasText(methodName, "'methodName' should not be empty");
112+
Assert.notNull(type, "'type' must not be null");
113+
Assert.hasText(methodName, "'methodName' must not be empty");
113114
return new MethodHintPredicate(getMethod(type, methodName));
114115
}
115116

@@ -125,8 +126,8 @@ public MethodHintPredicate onMethod(Class<?> type, String methodName) {
125126
* @throws IllegalArgumentException if the method cannot be found or if multiple methods are found with the same name.
126127
*/
127128
public MethodHintPredicate onMethod(String className, String methodName) throws ClassNotFoundException {
128-
Assert.hasText(className, "'className' should not be empty");
129-
Assert.hasText(methodName, "'methodName' should not be empty");
129+
Assert.hasText(className, "'className' must not be empty");
130+
Assert.hasText(methodName, "'methodName' must not be empty");
130131
return onMethod(Class.forName(className), methodName);
131132
}
132133

@@ -155,8 +156,8 @@ else if (methods.size() > 1) {
155156
* @throws IllegalArgumentException if a field cannot be found with the given name.
156157
*/
157158
public FieldHintPredicate onField(Class<?> type, String fieldName) {
158-
Assert.notNull(type, "'type' should not be null");
159-
Assert.hasText(fieldName, "'fieldName' should not be empty");
159+
Assert.notNull(type, "'type' must not be null");
160+
Assert.hasText(fieldName, "'fieldName' must not be empty");
160161
Field field = ReflectionUtils.findField(type, fieldName);
161162
if (field == null) {
162163
throw new IllegalArgumentException("No field named '%s' on class %s".formatted(fieldName, type.getName()));
@@ -176,8 +177,8 @@ public FieldHintPredicate onField(Class<?> type, String fieldName) {
176177
* @throws IllegalArgumentException if a field cannot be found with the given name.
177178
*/
178179
public FieldHintPredicate onField(String className, String fieldName) throws ClassNotFoundException {
179-
Assert.hasText(className, "'className' should not be empty");
180-
Assert.hasText(fieldName, "'fieldName' should not be empty");
180+
Assert.hasText(className, "'className' must not be empty");
181+
Assert.hasText(fieldName, "'fieldName' must not be empty");
181182
return onField(Class.forName(className), fieldName);
182183
}
183184

@@ -189,7 +190,7 @@ public FieldHintPredicate onField(String className, String fieldName) throws Cla
189190
* @return the {@link RuntimeHints} predicate
190191
*/
191192
public FieldHintPredicate onField(Field field) {
192-
Assert.notNull(field, "'field' should not be null");
193+
Assert.notNull(field, "'field' must not be null");
193194
return new FieldHintPredicate(field);
194195
}
195196

@@ -218,7 +219,7 @@ public boolean test(RuntimeHints hints) {
218219
* @return the refined {@link RuntimeHints} predicate
219220
*/
220221
public Predicate<RuntimeHints> withMemberCategory(MemberCategory memberCategory) {
221-
Assert.notNull(memberCategory, "'memberCategory' should not be null");
222+
Assert.notNull(memberCategory, "'memberCategory' must not be null");
222223
return this.and(hints -> getTypeHint(hints).getMemberCategories().contains(memberCategory));
223224
}
224225

@@ -228,7 +229,7 @@ public Predicate<RuntimeHints> withMemberCategory(MemberCategory memberCategory)
228229
* @return the refined {@link RuntimeHints} predicate
229230
*/
230231
public Predicate<RuntimeHints> withMemberCategories(MemberCategory... memberCategories) {
231-
Assert.notEmpty(memberCategories, "'memberCategories' should not be empty");
232+
Assert.notEmpty(memberCategories, "'memberCategories' must not be empty");
232233
return this.and(hints -> getTypeHint(hints).getMemberCategories().containsAll(Arrays.asList(memberCategories)));
233234
}
234235

@@ -238,7 +239,7 @@ public Predicate<RuntimeHints> withMemberCategories(MemberCategory... memberCate
238239
* @return the refined {@link RuntimeHints} predicate
239240
*/
240241
public Predicate<RuntimeHints> withAnyMemberCategory(MemberCategory... memberCategories) {
241-
Assert.notEmpty(memberCategories, "'memberCategories' should not be empty");
242+
Assert.notEmpty(memberCategories, "'memberCategories' must not be empty");
242243
return this.and(hints -> Arrays.stream(memberCategories)
243244
.anyMatch(memberCategory -> getTypeHint(hints).getMemberCategories().contains(memberCategory)));
244245
}

spring-core/src/main/java/org/springframework/aot/hint/predicate/SerializationHintsPredicates.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class SerializationHintsPredicates {
3535
SerializationHintsPredicates() {
3636
}
3737

38+
3839
/**
3940
* Return a predicate that checks whether a {@link SerializationHints
4041
* serialization hint} is registered for the given type.
@@ -43,7 +44,7 @@ public class SerializationHintsPredicates {
4344
* @see java.lang.reflect.Proxy
4445
*/
4546
public Predicate<RuntimeHints> onType(Class<?> type) {
46-
Assert.notNull(type, "'type' should not be null");
47+
Assert.notNull(type, "'type' must not be null");
4748
return onType(TypeReference.of(type));
4849
}
4950

@@ -55,7 +56,7 @@ public Predicate<RuntimeHints> onType(Class<?> type) {
5556
* @see java.lang.reflect.Proxy
5657
*/
5758
public Predicate<RuntimeHints> onType(TypeReference typeReference) {
58-
Assert.notNull(typeReference, "'typeReference' should not be null");
59+
Assert.notNull(typeReference, "'typeReference' must not be null");
5960
return hints -> hints.serialization().javaSerializationHints().anyMatch(
6061
hint -> hint.getType().equals(typeReference));
6162
}

spring-core/src/main/java/org/springframework/core/convert/converter/Converter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public interface Converter<S, T> {
5757
* @since 5.3
5858
*/
5959
default <U> Converter<S, U> andThen(Converter<? super T, ? extends U> after) {
60-
Assert.notNull(after, "After Converter must not be null");
60+
Assert.notNull(after, "'after' Converter must not be null");
6161
return (S s) -> {
6262
T initialResult = convert(s);
6363
return (initialResult != null ? after.convert(initialResult) : null);

0 commit comments

Comments
 (0)