############################################################################## ## ## Available variables: ## ## $packageName - The package name. (string) ## $className - The class name. (string) ## $project - The project name. (string) ## $epoch - The build epoch/unix time. (long) ## $major - The major version. (int) ## $minor - The minor version. (int) ## $patch - The patch version. (int) ## $prerelease - The pre-release version. (string) ## $buildmeta - The build metadata version. (string) ## ############################################################################## /* * This file is automatically generated. * Do not modify! -- ALL CHANGES WILL BE ERASED! */ package ${packageName}; import java.time.*; /** * Provides semantic version information. * * @author Semantic Version * Annotation Processor */ public final class ${className} { private final static String buildmeta = "${buildmeta}"; private final static LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(${epoch}L), ZoneId.systemDefault()); private final static int major = ${major}; private final static int minor = ${minor}; private final static int patch = ${patch}; private final static String prerelease = "${prerelease}"; private final static String project = "${project}"; /** * Disables the default constructor. * * @throws UnsupportedOperationException If the constructor is called. */ private ${className}() throws UnsupportedOperationException { throw new UnsupportedOperationException("Illegal constructor call."); } /** * Returns the build date. * * @return The build date. */ public static LocalDateTime getBuildDate() { return date; } /** * Returns the project name. * * @return The project name, if any. */ public static String getProject() { return project; } /** * Returns the full version string. *

* Formatted as: *

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

* For example: *

* * @return The version string. */ public static String getVersion() { return Integer.toString(getMajor()) + '.' + Integer.toString(getMinor()) + '.' + Integer.toString(getPatch()) + getPreRelease(true) + getBuildMetadata(true); } /** * Returns the major version. * * @return The major version. */ public static int getMajor() { return major; } /** * Returns the minor version. * * @return The minor version. */ public static int getMinor() { return minor; } /** * Returns the patch version. * * @return The patch version. */ public static int getPatch() { return patch; } /** * Returns the pre-release version. * * @param isHyphen Prepend a hyphen, if true. * @return The pre-release version, if any. */ public static String getPreRelease(final boolean isHyphen) { if (prerelease.length() > 0) { if (isHyphen) { return '-' + prerelease; } else { return prerelease; } } return ""; } /** * Returns the pre-release version. * * @return The pre-release version, if any. */ public static String getPreRelease() { return getPreRelease(false); } /** * Returns the build metadata. * * @param isPlus Prepend a plus sign, if true. * @return The build metadata, if any. */ public static String getBuildMetadata(final boolean isPlus) { if (buildmeta.length() > 0) { if (isPlus) { return '+' + buildmeta; } else { return buildmeta; } } return ""; } /** * Returns the build metadata. * * @return The build metadata, if any. */ public static String getBuildMetadata() { return getBuildMetadata(false); } }