semver/src/main/resources/semver.mustache

104 lines
No EOL
3 KiB
Text

/*
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
package {{packageName}};
import java.util.Date;
/**
* Provides semantic version information.
*
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
* Annotation Processor</a>
*/
public final class {{className}} {
private final static String DEFAULT_PRERELEASE_PREFIX = "-";
private final static String DEFAULT_BUILDMETA_PREFIX = "+";
final static String project = "{{project}}";
final static Date buildDate = new Date({{epoch}}L);
final static int major = {{major}};
final static int minor = {{minor}};
final static int patch = {{patch}};
final static String preRelease = "{{preRelease}}";
final static String buildMeta = "{{buildMeta}}";
/**
* 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>
*/
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;
}
}
/**
* Returns the pre-release version with default prefix.
*
* @return The pre-release version, if any.
*/
public static String preReleaseWithPrefix() {
return preReleaseWithPrefix(DEFAULT_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;
}
}
}