PMD optimizations.

This commit is contained in:
Erik C. Thauvin 2016-01-25 11:57:18 -08:00
parent 4c66bf6299
commit 5683ff853c
8 changed files with 70 additions and 18 deletions

View file

@ -108,7 +108,7 @@ public final class Constants
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException if an error occurred. if the constructor is called.
* @throws UnsupportedOperationException if the constructor is called.
*/
private Constants()
throws UnsupportedOperationException

View file

@ -207,7 +207,7 @@ public class VersionInfo
*
* @param project The new project name.
*/
public void setProject(String project)
public void setProject(final String project)
{
this.project = project;
}
@ -230,7 +230,7 @@ public class VersionInfo
*/
public String getVersion()
{
return "" + major + '.' + minor + '.' + patch + (prerelease.length() > 0 ? '-' + prerelease : "") + (
buildmeta.length() > 0 ? '+' + buildmeta : "");
return Integer.toString(major) + '.' + Integer.toString(minor) + '.' + Integer.toString(patch) + (
prerelease.length() > 0 ? '-' + prerelease : "") + (buildmeta.length() > 0 ? '+' + buildmeta : "");
}
}

View file

@ -170,7 +170,7 @@ public class VersionProcessor extends AbstractProcessor
}
catch (IOException e)
{
error("IOException occurred while running annotation processor", e);
error("IOException occurred while running the annotation processor", e);
}
}
}
@ -192,7 +192,7 @@ public class VersionProcessor extends AbstractProcessor
{
try
{
return Integer.parseInt(p.getProperty(property, "" + defaultValue));
return Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)));
}
catch (NumberFormatException ignore)
{

View file

@ -30,12 +30,28 @@ public final class ${className} {
}
/**
* Returns the full version.
* Returns the full version string.
* <p>
* Formatted as:
* <blockquote>
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
* </blockquote>
* <p>
* For example:
* <ul>
* <li><code>1.0.0</code></li>
* <li><code>1.0.0-beta</code></li>
* <li><code>1.0.0+20160124144700</code></li>
* <li><code>1.0.0-alpha+001</code></li>
* </ul>
*
* @return The full version string.
* @return The version string.
*/
public static String getVersion() {
return "" + getMajor() + '.' + getMinor() + '.' + getPatch() + getPreRelease() + getBuildMetadata();
return Integer.toString(getMajor()) + '.'
+ Integer.toString(getMinor()) + '.'
+ Integer.toString(getPatch())
+ getPreRelease() + getBuildMetadata();
}
/**
@ -99,4 +115,14 @@ public final class ${className} {
return "";
}
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException if the constructor is called.
*/
private ${className}()
throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
}