Use Supplier variants of Assert methods

See gh-12630
This commit is contained in:
dreis2211
2018-03-25 19:10:31 +02:00
committed by Stephane Nicoll
parent d771485efb
commit 3b0f6e7168
18 changed files with 33 additions and 30 deletions

View File

@@ -129,8 +129,9 @@ public class AutoConfigurationImportSelector
AnnotationAttributes attributes = AnnotationAttributes
.fromMap(metadata.getAnnotationAttributes(name, true));
Assert.notNull(attributes,
"No auto-configuration attributes found. Is " + metadata.getClassName()
+ " annotated with " + ClassUtils.getShortName(name) + "?");
() -> "No auto-configuration attributes found. Is "
+ metadata.getClassName() + " annotated with "
+ ClassUtils.getShortName(name) + "?");
return attributes;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -149,7 +149,7 @@ public class CacheAutoConfiguration {
@PostConstruct
public void checkHasCacheManager() {
Assert.notNull(this.cacheManager,
"No cache manager could "
() -> "No cache manager could "
+ "be auto-configured, check your configuration (caching "
+ "type is '" + this.cacheProperties.getType() + "')");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,7 +107,7 @@ public class CacheProperties {
*/
public Resource resolveConfigLocation(Resource config) {
if (config != null) {
Assert.isTrue(config.exists(), "Cache configuration does not exist '"
Assert.isTrue(config.exists(), () -> "Cache configuration does not exist '"
+ config.getDescription() + "'");
return config;
}

View File

@@ -503,8 +503,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
@Override
protected void validate(BeanTypeDeductionException ex) {
Assert.isTrue(getTypes().size() == 1, annotationName() + " annotations must "
+ "specify only one type (got " + getTypes() + ")");
Assert.isTrue(getTypes().size() == 1, () -> annotationName()
+ " annotations must specify only one type (got " + getTypes() + ")");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ public class HazelcastProperties {
if (this.config == null) {
return null;
}
Assert.isTrue(this.config.exists(), "Hazelcast configuration does not exist '"
Assert.isTrue(this.config.exists(), () -> "Hazelcast configuration does not exist '"
+ this.config.getDescription() + "'");
return this.config;
}

View File

@@ -323,8 +323,8 @@ public class JacksonAutoConfiguration {
// that may be added by Jackson in the future)
Field field = ReflectionUtils.findField(PropertyNamingStrategy.class,
fieldName, PropertyNamingStrategy.class);
Assert.notNull(field, "Constant named '" + fieldName + "' not found on "
+ PropertyNamingStrategy.class.getName());
Assert.notNull(field, () -> "Constant named '" + fieldName
+ "' not found on " + PropertyNamingStrategy.class.getName());
try {
builder.propertyNamingStrategy(
(PropertyNamingStrategy) field.get(null));