Merge pull request #39585 from qlido

* pr/39585:
  Polish "Change Banner declaration with new Java Syntax"
  Change Banner declaration with new Java Syntax

Closes gh-39585
This commit is contained in:
Moritz Halbritter
2024-02-16 09:09:36 +01:00
2 changed files with 11 additions and 10 deletions

View File

@@ -30,10 +30,14 @@ import org.springframework.core.env.Environment;
*/
class SpringBootBanner implements Banner {
private static final String[] BANNER = { "", " . ____ _ __ _ _",
" /\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\", "( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\",
" \\\\/ ___)| |_)| | | | | || (_| | ) ) ) )", " ' |____| .__|_| |_|_| |_\\__, | / / / /",
" =========|_|==============|___/=/_/_/_/" };
private static final String BANNER = """
. ____ _ __ _ _
/\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\
( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\
\\\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\\__, | / / / /
=========|_|==============|___/=/_/_/_/
""";
private static final String SPRING_BOOT = " :: Spring Boot :: ";
@@ -41,16 +45,12 @@ class SpringBootBanner implements Banner {
@Override
public void printBanner(Environment environment, Class<?> sourceClass, PrintStream printStream) {
for (String line : BANNER) {
printStream.println(line);
}
String version = SpringBootVersion.getVersion();
version = (version != null) ? " (v" + version + ")" : "";
printStream.println(BANNER);
String version = String.format(" (v%s)", SpringBootVersion.getVersion());
StringBuilder padding = new StringBuilder();
while (padding.length() < STRAP_LINE_SIZE - (version.length() + SPRING_BOOT.length())) {
padding.append(" ");
}
printStream.println(AnsiOutput.toString(AnsiColor.GREEN, SPRING_BOOT, AnsiColor.DEFAULT, padding.toString(),
AnsiStyle.FAINT, version));
printStream.println();

View File

@@ -82,4 +82,5 @@
<suppress files="ImportTestcontainersTests\.java" checks="InterfaceIsType" />
<suppress files="MyContainers\.java" checks="InterfaceIsType" />
<suppress files="CertificateMatchingTest\.java" checks="SpringTestFileName" />
<suppress files="SpringBootBanner\.java" checks="SpringLeadingWhitespace" />
</suppressions>