Improved templates.

This commit is contained in:
Erik C. Thauvin 2019-04-01 19:31:31 -07:00
parent eb907c33fa
commit 77a1b1cf14
3 changed files with 71 additions and 5 deletions

View file

@ -0,0 +1,33 @@
/*
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
package {{packageName}};
import java.util.Date;
public final class {{className}} {
public final static String PROJECT = "{{project}}";
public final static Date BUILDDATE = new Date({{epoch}}L);
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 semantic version string.
*/
public final static String VERSION = Integer.toString(MAJOR) + '.'
+ Integer.toString(MINOR) + '.'
+ Integer.toString(PATCH)
+ ((!PRERELEASE.isEmpty()) ? "-" + PRERELEASE : "")
+ ((!BUILDMETA.isEmpty()) ? "+" + BUILDMETA : "");
/**
* Disables the default constructor.
*/
private {{className}}() {
throw new UnsupportedOperationException("Illegal constructor call.");
}
}

View file

@ -0,0 +1,36 @@
/*
* 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>
*/
object {{className}} {
@JvmField
val PROJECT = "{{project}}"
@JvmField
val BUILDDATE = Date({{epoch}}L)
@JvmField
val MAJOR = {{major}}
@JvmField
val MINOR = {{minor}}
@JvmField
val PATCH = {{patch}}
@JvmField
val PRERELEASE = "{{preRelease}}"
@JvmField
val BUILDMETA = "{{buildMeta}}"
/**
* The full semantic version string.
*/
@JvmField
val VERSION = ("$MAJOR.$MINOR.$PATCH" + if (PRERELEASE.isNotEmpty()) "-$PRERELEASE" else ""
+ if (BUILDMETA.isNotEmpty()) "+$BUILDMETA" else "")
}

View file

@ -31,11 +31,8 @@ public final class {{className}} {
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException If the constructor is called.
*/
private {{className}}()
throws UnsupportedOperationException {
private {{className}}() {
throw new UnsupportedOperationException("Illegal constructor call.");
}