Polish assertions

This commit is contained in:
Stephane Nicoll
2022-06-21 07:57:11 +02:00
parent 93b340e563
commit 0f4205adbf
16 changed files with 61 additions and 61 deletions

View File

@@ -58,7 +58,7 @@ public class AotFactoriesLoader {
* @param beanFactory the bean factory to use
*/
public AotFactoriesLoader(ListableBeanFactory beanFactory) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
Assert.notNull(beanFactory, "'beanFactory' must not be null");
ClassLoader classLoader = (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory)
? configurableBeanFactory.getBeanClassLoader() : null;
this.beanFactory = beanFactory;
@@ -76,8 +76,8 @@ public class AotFactoriesLoader {
public AotFactoriesLoader(ListableBeanFactory beanFactory,
SpringFactoriesLoader factoriesLoader) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
Assert.notNull(factoriesLoader, "FactoriesLoader must not be null");
Assert.notNull(beanFactory, "'beanFactory' must not be null");
Assert.notNull(factoriesLoader, "'factoriesLoader' must not be null");
this.beanFactory = beanFactory;
this.factoriesLoader = factoriesLoader;
}

View File

@@ -80,7 +80,7 @@ public interface AutowiredArguments {
* @return a new {@link AutowiredArguments} instance
*/
static AutowiredArguments of(Object[] arguments) {
Assert.notNull(arguments, "Arguments must not be null");
Assert.notNull(arguments, "'arguments' must not be null");
return () -> arguments;
}

View File

@@ -66,8 +66,8 @@ public class AutowiredArgumentsCodeGenerator {
public CodeBlock generateCode(Class<?>[] parameterTypes, int startIndex,
String variableName) {
Assert.notNull(parameterTypes, "ParameterTypes must not be null");
Assert.notNull(variableName, "VariableName must not be null");
Assert.notNull(parameterTypes, "'parameterTypes' must not be null");
Assert.notNull(variableName, "'variableName' must not be null");
boolean ambiguous = isAmbiguous();
CodeBlock.Builder builder = CodeBlock.builder();
for (int i = startIndex; i < parameterTypes.length; i++) {

View File

@@ -64,7 +64,7 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver
private AutowiredFieldValueResolver(String fieldName, boolean required,
@Nullable String shortcut) {
Assert.hasText(fieldName, "FieldName must not be empty");
Assert.hasText(fieldName, "'fieldName' must not be empty");
this.fieldName = fieldName;
this.required = required;
this.shortcut = shortcut;
@@ -110,8 +110,8 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver
* @param action the action to execute with the resolved field value
*/
public <T> void resolve(RegisteredBean registeredBean, ThrowingConsumer<T> action) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(action, "Action must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
Assert.notNull(action, "'action' must not be null");
T resolved = resolve(registeredBean);
if (resolved != null) {
action.accept(resolved);
@@ -150,7 +150,7 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver
*/
@Nullable
public Object resolveObject(RegisteredBean registeredBean) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
return resolveValue(registeredBean, getField(registeredBean));
}
@@ -161,8 +161,8 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver
* @param instance the bean instance
*/
public void resolveAndSet(RegisteredBean registeredBean, Object instance) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(instance, "Instance must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
Assert.notNull(instance, "'instance' must not be null");
Field field = getField(registeredBean);
Object resolved = resolveValue(registeredBean, field);
if (resolved != null) {

View File

@@ -94,9 +94,9 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem
public static AutowiredInstantiationArgumentsResolver forConstructor(
Class<?>... parameterTypes) {
Assert.notNull(parameterTypes, "ParameterTypes must not be null");
Assert.notNull(parameterTypes, "'parameterTypes' must not be null");
Assert.noNullElements(parameterTypes,
"ParameterTypes must not contain null elements");
"'parameterTypes' must not contain null elements");
return new AutowiredInstantiationArgumentsResolver(
new ConstructorLookup(parameterTypes), null);
}
@@ -112,11 +112,11 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem
public static AutowiredInstantiationArgumentsResolver forFactoryMethod(
Class<?> declaringClass, String methodName, Class<?>... parameterTypes) {
Assert.notNull(declaringClass, "DeclaringClass must not be null");
Assert.hasText(methodName, "MethodName must not be empty");
Assert.notNull(parameterTypes, "ParameterTypes must not be null");
Assert.notNull(declaringClass, "'declaringClass' must not be null");
Assert.hasText(methodName, "'methodName' must not be empty");
Assert.notNull(parameterTypes, "'parameterTypes' must not be null");
Assert.noNullElements(parameterTypes,
"ParameterTypes must not contain null elements");
"'parameterTypes' must not contain null elements");
return new AutowiredInstantiationArgumentsResolver(
new FactoryMethodLookup(declaringClass, methodName, parameterTypes),
null);
@@ -149,8 +149,8 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem
public <T> T resolve(RegisteredBean registeredBean,
ThrowingFunction<AutowiredArguments, T> generator) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(generator, "Action must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
Assert.notNull(generator, "'action' must not be null");
AutowiredArguments resolved = resolveArguments(registeredBean,
this.lookup.get(registeredBean));
return generator.apply(resolved);
@@ -162,7 +162,7 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem
* @return the resolved constructor or factory method arguments
*/
public AutowiredArguments resolve(RegisteredBean registeredBean) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
return resolveArguments(registeredBean, this.lookup.get(registeredBean));
}
@@ -188,8 +188,8 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem
public <T> T resolveAndInstantiate(RegisteredBean registeredBean,
Class<T> requiredType) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(registeredBean, "RequiredType must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
Assert.notNull(registeredBean, "'requiredType' must not be null");
Executable executable = this.lookup.get(registeredBean);
AutowiredArguments arguments = resolveArguments(registeredBean, executable);
Object instance = instantiate(registeredBean.getBeanFactory(), executable,

View File

@@ -69,7 +69,7 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso
private AutowiredMethodArgumentsResolver(String methodName, Class<?>[] parameterTypes,
boolean required, @Nullable String[] shortcuts) {
Assert.hasText(methodName, "MethodName must not be empty");
Assert.hasText(methodName, "'methodName' must not be empty");
this.methodName = methodName;
this.parameterTypes = parameterTypes;
this.required = required;
@@ -126,8 +126,8 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso
public void resolve(RegisteredBean registeredBean,
ThrowingConsumer<AutowiredArguments> action) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(action, "Action must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
Assert.notNull(action, "'action' must not be null");
AutowiredArguments resolved = resolve(registeredBean);
if (resolved != null) {
action.accept(resolved);
@@ -141,7 +141,7 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso
*/
@Nullable
public AutowiredArguments resolve(RegisteredBean registeredBean) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
return resolveArguments(registeredBean, getMethod(registeredBean));
}
@@ -152,8 +152,8 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso
* @param instance the bean instance
*/
public void resolveAndInvoke(RegisteredBean registeredBean, Object instance) {
Assert.notNull(registeredBean, "RegisteredBean must not be null");
Assert.notNull(instance, "Instance must not be null");
Assert.notNull(registeredBean, "'registeredBean' must not be null");
Assert.notNull(instance, "'instance' must not be null");
Method method = getMethod(registeredBean);
AutowiredArguments resolved = resolveArguments(registeredBean, method);
if (resolved != null) {

View File

@@ -53,7 +53,7 @@ public abstract class BeanRegistrationCodeFragments {
protected BeanRegistrationCodeFragments(BeanRegistrationCodeFragments codeFragments) {
Assert.notNull(codeFragments, "CodeFragments must not be null");
Assert.notNull(codeFragments, "'codeFragments' must not be null");
this.codeFragments = codeFragments;
}

View File

@@ -75,7 +75,7 @@ class BeanRegistrationCodeGenerator implements BeanRegistrationCode {
@Override
public void addInstancePostProcessor(MethodReference methodReference) {
Assert.notNull(methodReference, "MethodReference must not be null");
Assert.notNull(methodReference, "'methodReference' must not be null");
this.instancePostProcessors.add(methodReference);
}

View File

@@ -74,8 +74,8 @@ public final class RegisteredBean {
public static RegisteredBean of(ConfigurableBeanFactory beanFactory,
String beanName) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
Assert.hasLength(beanName, "BeanName must not be empty");
Assert.notNull(beanFactory, "'beanFactory' must not be null");
Assert.hasLength(beanName, "'beanName' must not be empty");
return new RegisteredBean(beanFactory, () -> beanName, false,
() -> (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName),
null);
@@ -90,7 +90,7 @@ public final class RegisteredBean {
public static RegisteredBean ofInnerBean(RegisteredBean parent,
BeanDefinitionHolder innerBean) {
Assert.notNull(innerBean, "InnerBean must not be null");
Assert.notNull(innerBean, "'innerBean' must not be null");
return ofInnerBean(parent, innerBean.getBeanName(),
innerBean.getBeanDefinition());
}
@@ -118,8 +118,8 @@ public final class RegisteredBean {
public static RegisteredBean ofInnerBean(RegisteredBean parent,
@Nullable String innerBeanName, BeanDefinition innerBeanDefinition) {
Assert.notNull(parent, "Parent must not be null");
Assert.notNull(innerBeanDefinition, "InnerBeanDefinition must not be null");
Assert.notNull(parent, "'parent' must not be null");
Assert.notNull(innerBeanDefinition, "'innerBeanDefinition' must not be null");
InnerBeanResolver resolver = new InnerBeanResolver(parent, innerBeanName,
innerBeanDefinition);
Supplier<String> beanName = StringUtils.hasLength(innerBeanName)