Skip to content

Commit d8e2349

Browse files
dreis2211snicoll
authored andcommitted
Use Supplier variants of Assert
See gh-19864
1 parent 9fbaf76 commit d8e2349

File tree

18 files changed

+28
-27
lines changed

18 files changed

+28
-27
lines changed

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FileSystemWatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -124,7 +124,7 @@ public void addSourceFolders(Iterable<File> folders) {
124124
*/
125125
public void addSourceFolder(File folder) {
126126
Assert.notNull(folder, "Folder must not be null");
127-
Assert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file");
127+
Assert.isTrue(!folder.isFile(), () -> "Folder '" + folder + "' must not be a file");
128128
synchronized (this.monitor) {
129129
checkNotStarted();
130130
this.folders.put(folder, null);

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FolderSnapshot.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -51,7 +51,7 @@ class FolderSnapshot {
5151
*/
5252
FolderSnapshot(File folder) {
5353
Assert.notNull(folder, "Folder must not be null");
54-
Assert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file");
54+
Assert.isTrue(!folder.isFile(), () -> "Folder '" + folder + "' must not be a file");
5555
this.folder = folder;
5656
this.time = new Date();
5757
Set<FileSnapshot> files = new LinkedHashSet<>();

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public String toString() {
121121
static ApiVersion parse(String value) {
122122
Assert.hasText(value, "Value must not be empty");
123123
Matcher matcher = PATTERN.matcher(value);
124-
Assert.isTrue(matcher.matches(), "Malformed version number '" + value + "'");
124+
Assert.isTrue(matcher.matches(), () -> "Malformed version number '" + value + "'");
125125
try {
126126
int major = Integer.parseInt(matcher.group(1));
127127
int minor = Integer.parseInt(matcher.group(2));

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildOwner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class BuildOwner implements Owner {
4949

5050
private long getValue(Map<String, String> env, String name) {
5151
String value = env.get(name);
52-
Assert.state(StringUtils.hasText(value), "Missing '" + name + "' value from the builder environment");
52+
Assert.state(StringUtils.hasText(value), () -> "Missing '" + name + "' value from the builder environment");
5353
try {
5454
return Long.parseLong(value);
5555
}

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuilderMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static BuilderMetadata fromImageConfig(ImageConfig imageConfig) throws IOExcepti
123123
Assert.notNull(imageConfig, "ImageConfig must not be null");
124124
Map<String, String> labels = imageConfig.getLabels();
125125
String json = (labels != null) ? labels.get(LABEL_NAME) : null;
126-
Assert.notNull(json, "No '" + LABEL_NAME + "' label found in image config");
126+
Assert.notNull(json, () -> "No '" + LABEL_NAME + "' label found in image config");
127127
return fromJson(json);
128128
}
129129

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/StackId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static StackId fromImage(Image image) {
7777
private static StackId fromImageConfig(ImageConfig imageConfig) {
7878
Map<String, String> labels = imageConfig.getLabels();
7979
String value = (labels != null) ? labels.get(LABEL_NAME) : null;
80-
Assert.state(StringUtils.hasText(value), "Missing '" + LABEL_NAME + "' stack label");
80+
Assert.state(StringUtils.hasText(value), () -> "Missing '" + LABEL_NAME + "' stack label");
8181
return new StackId(value);
8282
}
8383

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageReference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public ImageReference withDigest(String digest) {
151151
* @throws IllegalStateException if the image reference contains a digest
152152
*/
153153
public ImageReference inTaggedForm() {
154-
Assert.state(this.digest == null, "Image reference '" + this + "' cannot contain a digest");
154+
Assert.state(this.digest == null, () -> "Image reference '" + this + "' cannot contain a digest");
155155
return new ImageReference(this.name, (this.tag != null) ? this.tag : LATEST, this.digest);
156156
}
157157

@@ -163,7 +163,7 @@ public ImageReference inTaggedForm() {
163163
*/
164164
public static ImageReference forJarFile(File jarFile) {
165165
String filename = jarFile.getName();
166-
Assert.isTrue(filename.toLowerCase().endsWith(".jar"), "File '" + jarFile + "' is not a JAR");
166+
Assert.isTrue(filename.toLowerCase().endsWith(".jar"), () -> "File '" + jarFile + "' is not a JAR");
167167
filename = filename.substring(0, filename.length() - 4);
168168
int firstDot = filename.indexOf('.');
169169
if (firstDot == -1) {

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/LayerId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public String toString() {
8585
public static LayerId of(String value) {
8686
Assert.hasText(value, "Value must not be empty");
8787
int i = value.indexOf(':');
88-
Assert.isTrue(i >= 0, "Invalid layer ID '" + value + "'");
88+
Assert.isTrue(i >= 0, () -> "Invalid layer ID '" + value + "'");
8989
return new LayerId(value, value.substring(0, i), value.substring(i + 1));
9090
}
9191

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/VolumeName.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ private static String getDigest(String name, int length) {
124124
}
125125

126126
private static String asHexString(byte[] digest, int digestLength) {
127-
Assert.isTrue(digestLength <= digest.length, "DigestLength must be less than or equal to " + digest.length);
127+
Assert.isTrue(digestLength <= digest.length,
128+
() -> "DigestLength must be less than or equal to " + digest.length);
128129
byte[] shortDigest = new byte[6];
129130
System.arraycopy(digest, 0, shortDigest, 0, shortDigest.length);
130131
return String.format("%0" + digestLength + "x", new BigInteger(1, shortDigest));

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/MappedObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
200200
if (declaringClass == Object.class) {
201201
method.invoke(proxy, args);
202202
}
203-
Assert.state(args == null || args.length == 0, "Unsupported method " + method);
203+
Assert.state(args == null || args.length == 0, () -> "Unsupported method " + method);
204204
String name = getName(method.getName());
205205
Class<?> type = method.getReturnType();
206206
return valueForProperty(name, type);

0 commit comments

Comments
 (0)