Synchronized java and kotlin templates.

This commit is contained in:
Erik C. Thauvin 2017-04-16 14:21:17 -07:00
parent 80700b2ad7
commit 3f630c1b55
2 changed files with 42 additions and 47 deletions

View file

@ -34,9 +34,8 @@ object {{className}} {
@JvmField @JvmField
val preRelease = "{{preRelease}}" val preRelease = "{{preRelease}}"
@JvmStatic @JvmField
val version: String val version = "$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix()
get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix())
@JvmStatic @JvmStatic
fun preReleaseWithPrefix(prefix: String = "-"): String { fun preReleaseWithPrefix(prefix: String = "-"): String {

View file

@ -25,17 +25,7 @@ public final class {{className}} {
final static String buildMeta = "{{buildMeta}}"; final static String buildMeta = "{{buildMeta}}";
/** /**
* Disables the default constructor. * The full version string.
*
* @throws UnsupportedOperationException If the constructor is called.
*/
private {{className}}()
throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
/**
* Returns the full version string.
* <p> * <p>
* Formatted as: * Formatted as:
* <blockquote> * <blockquote>
@ -49,37 +39,20 @@ public final class {{className}} {
* <li><code>1.0.0+20160124144700</code></li> * <li><code>1.0.0+20160124144700</code></li>
* <li><code>1.0.0-alpha+001</code></li> * <li><code>1.0.0-alpha+001</code></li>
* </ul> * </ul>
*
* @return The version string.
*/ */
public static String getVersion() { final static String version = Integer.toString(major) + '.'
return Integer.toString(major) + '.'
+ Integer.toString(minor) + '.' + Integer.toString(minor) + '.'
+ Integer.toString(patch) + Integer.toString(patch)
+ preReleaseWithPrefix() + buildMetaWithPrefix(); + preReleaseWithPrefix() + buildMetaWithPrefix();
}
/** /**
* Returns the pre-release version with default prefix. * Disables the default constructor.
* *
* @return The pre-release version, if any. * @throws UnsupportedOperationException If the constructor is called.
*/ */
public static String preReleaseWithPrefix() { private GeneratedVersion()
return preReleaseWithPrefix(DEFAULT_PRERELEASE_PREFIX); throws UnsupportedOperationException {
} throw new UnsupportedOperationException("Illegal constructor call.");
/**
* 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;
}
} }
/** /**
@ -105,4 +78,27 @@ public final class {{className}} {
return buildMeta; 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;
}
}
} }