Polish 'Remove duplicated file.getName() call'
See gh-42411
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@@ -108,18 +108,13 @@ public class WebServerPortFileWriter implements ApplicationListener<WebServerIni
|
||||
if (!StringUtils.hasLength(namespace)) {
|
||||
return this.file;
|
||||
}
|
||||
String name = this.file.getName();
|
||||
String extension = StringUtils.getFilenameExtension(name);
|
||||
|
||||
StringBuilder builder = new StringBuilder(name);
|
||||
|
||||
String suffix = "-" + (isUpperCase(name) ? namespace.toUpperCase(Locale.ENGLISH) : namespace.toLowerCase(Locale.ENGLISH));
|
||||
if (StringUtils.hasLength(extension))
|
||||
builder.insert(name.lastIndexOf(extension) - 1, suffix);
|
||||
else
|
||||
builder.append(suffix);
|
||||
|
||||
return new File(this.file.getParentFile(), builder.toString());
|
||||
String filename = this.file.getName();
|
||||
String extension = StringUtils.getFilenameExtension(filename);
|
||||
String filenameWithoutExtension = filename.substring(0, filename.length() - extension.length() - 1);
|
||||
String suffix = (!isUpperCase(filename)) ? namespace.toLowerCase(Locale.ENGLISH)
|
||||
: namespace.toUpperCase(Locale.ENGLISH);
|
||||
return new File(this.file.getParentFile(),
|
||||
filenameWithoutExtension + "-" + suffix + ((!StringUtils.hasLength(extension)) ? "" : "." + extension));
|
||||
}
|
||||
|
||||
private String getServerNamespace(ApplicationContext applicationContext) {
|
||||
|
||||
Reference in New Issue
Block a user