Avoid String allocations with Assert.isTrue()

This commit is contained in:
Sam Brannen
2022-11-05 14:51:36 +01:00
parent 82823517fa
commit ac5eb9bfd3
6 changed files with 9 additions and 10 deletions

View File

@@ -86,7 +86,7 @@ public class FileSystemGeneratedFiles implements GeneratedFiles {
Assert.notNull(content, "'content' must not be null");
Path root = this.roots.apply(kind).toAbsolutePath().normalize();
Path relativePath = root.resolve(path).toAbsolutePath().normalize();
Assert.isTrue(relativePath.startsWith(root), () -> "'path' must be relative");
Assert.isTrue(relativePath.startsWith(root), "'path' must be relative");
try {
try (InputStream inputStream = content.getInputStream()) {
Files.createDirectories(relativePath.getParent());

View File

@@ -161,8 +161,7 @@ public interface GeneratedFiles {
private static String getClassNamePath(String className) {
Assert.hasLength(className, "'className' must not be empty");
Assert.isTrue(isJavaIdentifier(className),
"'className' must be a valid identifier");
Assert.isTrue(isJavaIdentifier(className), "'className' must be a valid identifier");
return ClassUtils.convertClassNameToResourcePath(className) + ".java";
}