mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
This commit is contained in:
parent
9c98d6470d
commit
7a8635eba2
4 changed files with 77 additions and 17 deletions
|
|
@ -1,7 +1,10 @@
|
|||
package de.kosit.validationtool.cmd;
|
||||
|
||||
import static org.apache.commons.io.FilenameUtils.isExtension;
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -18,27 +21,25 @@ public class DefaultNamingStrategy implements NamingStrategy {
|
|||
|
||||
private String prefix;
|
||||
|
||||
private String postfix = "report";
|
||||
private String postfix;
|
||||
|
||||
@Override
|
||||
public String createName(final String base) {
|
||||
if (StringUtils.isEmpty(base)) {
|
||||
public String createName(final String name) {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
throw new IllegalArgumentException("Can not generate name based on null input");
|
||||
}
|
||||
final int index = base.lastIndexOf('.');
|
||||
final String base = isExtension(name.toLowerCase(), "xml") ? FilenameUtils.getBaseName(name) : name;
|
||||
final StringBuilder result = new StringBuilder();
|
||||
if (isNotEmpty(this.prefix)) {
|
||||
result.append(this.prefix).append("-");
|
||||
}
|
||||
result.append(base, 0, index > 0 ? index : base.length());
|
||||
result.append(base);
|
||||
if (isNotEmpty(this.postfix)) {
|
||||
result.append("-").append(this.postfix);
|
||||
} else if (isEmpty(this.prefix)) {
|
||||
result.append("-").append("report");
|
||||
}
|
||||
if (index > 0) {
|
||||
result.append(base.substring(index));
|
||||
} else {
|
||||
result.append(".xml");
|
||||
}
|
||||
result.append(".xml");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue