diff --git a/src/main/resources/semver-kt.mustache b/src/main/resources/semver-kt.mustache index e46f7ef..dee8e90 100644 --- a/src/main/resources/semver-kt.mustache +++ b/src/main/resources/semver-kt.mustache @@ -34,9 +34,8 @@ object {{className}} { @JvmField val preRelease = "{{preRelease}}" - @JvmStatic - val version: String - get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix()) + @JvmField + val version = "$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix() @JvmStatic fun preReleaseWithPrefix(prefix: String = "-"): String { diff --git a/src/main/resources/semver.mustache b/src/main/resources/semver.mustache index c10de6b..44ed13d 100644 --- a/src/main/resources/semver.mustache +++ b/src/main/resources/semver.mustache @@ -25,17 +25,7 @@ public final class {{className}} { final static String buildMeta = "{{buildMeta}}"; /** - * Disables the default constructor. - * - * @throws UnsupportedOperationException If the constructor is called. - */ - private {{className}}() - throws UnsupportedOperationException { - throw new UnsupportedOperationException("Illegal constructor call."); - } - - /** - * Returns the full version string. + * The full version string. *

* Formatted as: *

@@ -49,14 +39,44 @@ public final class {{className}} { *
  • 1.0.0+20160124144700
  • *
  • 1.0.0-alpha+001
  • * - * - * @return The version string. */ - public static String getVersion() { - return Integer.toString(major) + '.' - + Integer.toString(minor) + '.' - + Integer.toString(patch) - + preReleaseWithPrefix() + buildMetaWithPrefix(); + final static String version = Integer.toString(major) + '.' + + Integer.toString(minor) + '.' + + Integer.toString(patch) + + preReleaseWithPrefix() + buildMetaWithPrefix(); + + /** + * Disables the default constructor. + * + * @throws UnsupportedOperationException If the constructor is called. + */ + private GeneratedVersion() + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Illegal constructor call."); + } + + /** + * Returns the build metadata with default prefix. + * + * @param prefix The prefix to prepend. + * @return The build metadata, if any. + */ + public static String buildMetaWithPrefix() { + return buildMetaWithPrefix(DEFAULT_PRERELEASE_PREFIX); + } + + /** + * Returns the build metadata. + * + * @param prefix Prefix to prepend. + * @return The build metadata, if any. + */ + public static String buildMetaWithPrefix(final String prefix) { + if (buildMeta.length() > 0 && prefix.length() > 0) { + return prefix + buildMeta; + } else { + return buildMeta; + } } /** @@ -76,33 +96,9 @@ public final class {{className}} { */ public static String preReleaseWithPrefix(final String prefix) { if (preRelease.length() > 0 && prefix.length() > 0) { - return prefix + preRelease; + return prefix + preRelease; } else { - return preRelease; - } - } - - /** - * Returns the build metadata with default prefix. - * - * @param prefix The prefix to prepend. - * @return The build metadata, if any. - */ - public static String buildMetaWithPrefix() { - return buildMetaWithPrefix(DEFAULT_PRERELEASE_PREFIX); - } - - /** - * Returns the build metadata. - * - * @param prefix Prefix to prepend. - * @return The build metadata, if any. - */ - public static String buildMetaWithPrefix(final String prefix) { - if (buildMeta.length() > 0 && prefix.length() > 0) { - return prefix + buildMeta; - } else { - return buildMeta; + return preRelease; } } } \ No newline at end of file