From 09ab2d5f8ed57b4d4a1c414b3a26e787bd597770 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 1 Apr 2019 17:43:10 -0700 Subject: [PATCH] Updated for semver 1.2.0. --- version.mustache | 81 +++++------------------------------------------- 1 file changed, 8 insertions(+), 73 deletions(-) diff --git a/version.mustache b/version.mustache index 8cb1997..c984841 100644 --- a/version.mustache +++ b/version.mustache @@ -9,96 +9,31 @@ import java.time.*; /** * Provides semantic version information. * - * @author Semantic Version - * Annotation Processor + * @author Semantic Version Annotation Processor */ public final class {{className}} { - public final static String PRERELEASE_PREFIX = "-"; - public final static String BUILDMETA_PREFIX = "+"; - public final static String PROJECT = "{{project}}"; public final static LocalDateTime BUILDDATE = - LocalDateTime.ofInstant(Instant.ofEpochMilli({{epoch}}L), ZoneId.systemDefault()); + LocalDateTime.ofInstant(Instant.ofEpochMilli({{epoch}}L), ZoneId.systemDefault()); public final static int MAJOR = {{major}}; public final static int MINOR = {{minor}}; public final static int PATCH = {{patch}}; public final static String PRERELEASE = "{{preRelease}}"; public final static String BUILDMETA = "{{buildMeta}}"; - /** - * The full version string. - *

- * Formatted as: - *

- * MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA] - *
- *

- * For example: - *

+ /** + * The full semantic version string. */ public final static String VERSION = Integer.toString(MAJOR) + '.' + Integer.toString(MINOR) + '.' + Integer.toString(PATCH) - + preReleaseWithPrefix() + buildMetaWithPrefix(); + + ((!PRERELEASE.isEmpty()) ? "-" + PRERELEASE : "") + + ((!BUILDMETA.isEmpty()) ? "+" + BUILDMETA : ""); /** * Disables the default constructor. - * - * @throws UnsupportedOperationException If the constructor is called. */ - private {{className}}() - throws UnsupportedOperationException { + private {{className}}() { throw new UnsupportedOperationException("Illegal constructor call."); } - - /** - * Returns the build metadata with {@value #BUILDMETA_PREFIX} prefix. - * - * @return The build metadata, if any. - */ - public static String buildMetaWithPrefix() { - return buildMetaWithPrefix(BUILDMETA_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; - } - } - - /** - * Returns the pre-release version with {@value #PRERELEASE_PREFIX} prefix. - * - * @return The pre-release version, if any. - */ - public static String preReleaseWithPrefix() { - return preReleaseWithPrefix(PRERELEASE_PREFIX); - } - - /** - * Returns the pre-release version. - * - * @param prefix The prefix to prepend. - * @return The pre-release version, if any. - */ - public static String preReleaseWithPrefix(final String prefix) { - if (PRERELEASE.length() > 0 && prefix.length() > 0) { - return prefix + PRERELEASE; - } else { - return PRERELEASE; - } - } -} \ No newline at end of file +}