Improved if statement logic (PMD).
This commit is contained in:
parent
f801ce03fe
commit
72a955217e
1 changed files with 21 additions and 22 deletions
|
@ -178,26 +178,6 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
messager = processingEnv.getMessager();
|
messager = processingEnv.getMessager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void log(final Diagnostic.Kind kind, final String s) {
|
|
||||||
if (messager != null) {
|
|
||||||
messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s
|
|
||||||
+ System.lineSeparator());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void note(final String s) {
|
|
||||||
log(Diagnostic.Kind.NOTE, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int parseIntProperty(final Properties p, final String property, final int defaultValue) {
|
|
||||||
try {
|
|
||||||
return Math.abs(Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)).trim()));
|
|
||||||
} catch (NumberFormatException ignore) {
|
|
||||||
warn("Invalid property value: " + property);
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -217,8 +197,7 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
note("Found version: " + versionInfo.getVersion());
|
note("Found version: " + versionInfo.getVersion());
|
||||||
final String template;
|
final String template;
|
||||||
if (Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template())
|
if (isLocalTemplate && Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template())) {
|
||||||
&& isLocalTemplate) {
|
|
||||||
template = Constants.DEFAULT_TEMPLATE_NAME;
|
template = Constants.DEFAULT_TEMPLATE_NAME;
|
||||||
} else if (Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template())
|
} else if (Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template())
|
||||||
&& Constants.KOTLIN_TYPE.equals(version.type())) {
|
&& Constants.KOTLIN_TYPE.equals(version.type())) {
|
||||||
|
@ -237,6 +216,26 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void log(final Diagnostic.Kind kind, final String s) {
|
||||||
|
if (messager != null) {
|
||||||
|
messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s
|
||||||
|
+ System.lineSeparator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void note(final String s) {
|
||||||
|
log(Diagnostic.Kind.NOTE, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int parseIntProperty(final Properties p, final String property, final int defaultValue) {
|
||||||
|
try {
|
||||||
|
return Math.abs(Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)).trim()));
|
||||||
|
} catch (NumberFormatException ignore) {
|
||||||
|
warn("Invalid property value: " + property);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void warn(final String s) {
|
private void warn(final String s) {
|
||||||
log(Diagnostic.Kind.WARNING, s);
|
log(Diagnostic.Kind.WARNING, s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue