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,14 +39,44 @@ 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();
/**
* 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;
}
} }
/** /**
@ -76,33 +96,9 @@ public final class {{className}} {
*/ */
public static String preReleaseWithPrefix(final String prefix) { public static String preReleaseWithPrefix(final String prefix) {
if (preRelease.length() > 0 && prefix.length() > 0) { if (preRelease.length() > 0 && prefix.length() > 0) {
return prefix + preRelease; return prefix + preRelease;
} else { } else {
return preRelease; return preRelease;
}
}
/**
* 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;
} }
} }
} }