Commit 2eba1c5f authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Use Assert.state() with Supplier where possible"

Closes gh-10658
parent 3b71393e
...@@ -93,8 +93,8 @@ public final class CommandLineInvoker { ...@@ -93,8 +93,8 @@ public final class CommandLineInvoker {
} }
File bin = new File(unpacked.listFiles()[0], "bin"); File bin = new File(unpacked.listFiles()[0], "bin");
File launchScript = new File(bin, isWindows() ? "spring.bat" : "spring"); File launchScript = new File(bin, isWindows() ? "spring.bat" : "spring");
Assert.state(launchScript.exists() && launchScript.isFile(), Assert.state(launchScript.exists() && launchScript.isFile(), () ->
() -> "Could not find CLI launch script " + launchScript.getAbsolutePath()); "Could not find CLI launch script " + launchScript.getAbsolutePath());
return launchScript; return launchScript;
} }
......
...@@ -109,8 +109,8 @@ class DefinitionsParser { ...@@ -109,8 +109,8 @@ class DefinitionsParser {
private void addDefinition(AnnotatedElement element, Definition definition, private void addDefinition(AnnotatedElement element, Definition definition,
String type) { String type) {
boolean isNewDefinition = this.definitions.add(definition); boolean isNewDefinition = this.definitions.add(definition);
Assert.state(isNewDefinition, Assert.state(isNewDefinition, () ->
() -> "Duplicate " + type + " definition " + definition); "Duplicate " + type + " definition " + definition);
if (element instanceof Field) { if (element instanceof Field) {
Field field = (Field) element; Field field = (Field) element;
this.definitionFields.put(definition, field); this.definitionFields.put(definition, field);
......
...@@ -91,7 +91,8 @@ public class ApplicationTemp { ...@@ -91,7 +91,8 @@ public class ApplicationTemp {
Assert.state(StringUtils.hasLength(property), "No 'java.io.tmpdir' property set"); Assert.state(StringUtils.hasLength(property), "No 'java.io.tmpdir' property set");
File file = new File(property); File file = new File(property);
Assert.state(file.exists(), () -> "Temp directory" + file + " does not exist"); Assert.state(file.exists(), () -> "Temp directory" + file + " does not exist");
Assert.state(file.isDirectory(), () -> "Temp location " + file + " is not a directory"); Assert.state(file.isDirectory(), () -> "Temp location " + file
+ " is not a directory");
return file; return file;
} }
......
...@@ -92,8 +92,8 @@ public class JettyWebServer implements WebServer { ...@@ -92,8 +92,8 @@ public class JettyWebServer implements WebServer {
@Override @Override
protected void doStart() throws Exception { protected void doStart() throws Exception {
for (Connector connector : JettyWebServer.this.connectors) { for (Connector connector : JettyWebServer.this.connectors) {
Assert.state(connector.isStopped(), () -> "Connector " + connector Assert.state(connector.isStopped(), () -> "Connector "
+ " has been started prematurely"); + connector + " has been started prematurely");
} }
JettyWebServer.this.server.setConnectors(null); JettyWebServer.this.server.setConnectors(null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment