Skip to content

Commit

Permalink
fixed some spotbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw committed May 15, 2024
1 parent a80e090 commit 7343620
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Collection<Class<? extends AbstractBuilder>> getClasses() {
return Collections.unmodifiableCollection(matcherBuilders.values());
}

private void addBuilderImpl(final String className, String name) {
private void addBuilderImpl(final String className, final String name) {
Objects.requireNonNull(className, "className may not be null");
Class<?> clazz;
try {
Expand All @@ -106,20 +106,21 @@ private void addBuilderImpl(final String className, String name) {
if (AbstractBuilder.class.isAssignableFrom(clazz)) {
@SuppressWarnings("unchecked")
Class<? extends AbstractBuilder> candidate = (Class<? extends AbstractBuilder>) clazz;
if (StringUtils.isBlank(name)) {
name = candidate.getSimpleName();
if (!name.endsWith("Builder")) {
String workingName = name;
if (StringUtils.isBlank(workingName)) {
workingName = candidate.getSimpleName();
if (!workingName.endsWith("Builder")) {
throw new ConfigurationException(
"name is required, or " + candidate.getName() + " must end with 'Builder'");
}
name = name.substring(0, name.lastIndexOf("Builder"));
if (StringUtils.isBlank(name)) {
workingName = workingName.substring(0, workingName.lastIndexOf("Builder"));
if (StringUtils.isBlank(workingName)) {
throw new ConfigurationException("Last segment of " + candidate.getName()
+ " may not be 'Builder', but must end in 'Builder'");
}
name = WordUtils.uncapitalize(name);
workingName = WordUtils.uncapitalize(workingName);
}
matcherBuilders.put(name, candidate);
matcherBuilders.put(workingName, candidate);
} else {
throw new ConfigurationException("Class " + clazz.getName() + " does not extend " + AbstractBuilder.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
/**
* A class that reads the XML configuration file format.
*/
public class XMLConfigurationReader implements LicenseReader, MatcherReader {
public final class XMLConfigurationReader implements LicenseReader, MatcherReader {

private Log log;
private Document document;
Expand Down Expand Up @@ -127,6 +127,10 @@ public void setLog(Log log) {
this.log = log;
}

/**
* Returns the log the reader.
* @return the log if set, if not set {@code DefaultLog.getInstance()} is returned.
*/
public Log getLog() {
return log == null ? DefaultLog.getInstance() : log;
}
Expand All @@ -138,7 +142,7 @@ public void addLicenses(URL url) {

/**
* Read xml from a reader.
*
*
* @param reader the reader to read XML from.
*/
public void read(Reader reader) {
Expand Down

0 comments on commit 7343620

Please sign in to comment.