From 3859fbff6761e38b282edf399d087fcac45f66cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 13 Apr 2008 03:07:41 +0000 Subject: [PATCH] improve versioning git-svn-id: http://trooper/svn/projects/jSite/trunk@750 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/jsite/main/Version.java | 103 ++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 6 deletions(-) diff --git a/src/net/pterodactylus/jsite/main/Version.java b/src/net/pterodactylus/jsite/main/Version.java index 361b5ed..4148fc7 100644 --- a/src/net/pterodactylus/jsite/main/Version.java +++ b/src/net/pterodactylus/jsite/main/Version.java @@ -25,18 +25,109 @@ package net.pterodactylus.jsite.main; * @author David Roden <bombe@freenetproject.org> * @version $Id$ */ -public class Version { +public class Version implements Comparable { - /** The version identifier. */ - private static final String VERSION = "0.9.0"; + /** The version of the application. */ + private static final Version VERSION = new Version(0, 9, 0); + + /** The major level of the version. */ + private final int major; + + /** The minor level of the version. */ + private final int minor; + + /** The patch level of the version. */ + private final int patch; /** - * Returns the version information. + * Creates a new version with the given major level and minor and patch + * levels set to 0. * - * @return The version information + * @param major + * The major level of the version */ - public static final String getVersion() { + public Version(int major) { + this(major, 0); + } + + /** + * Creates a new version with the given major and minor level and the patch + * level set to 0. + * + * @param major + * The major level of the version + * @param minor + * The minor level of the version + */ + public Version(int major, int minor) { + this(major, minor, 0); + } + + /** + * Creates a new version with the given major, minor, and patch level. + * + * @param major + * The major level of the version + * @param minor + * The minor level of the version + * @param patch + * The patch level of the version + */ + public Version(int major, int minor, int patch) { + this.major = major; + this.minor = minor; + this.patch = patch; + } + + /** + * Returns the version of the application. + * + * @return The version of the application + */ + public static Version getVersion() { return VERSION; } + /** + * Returns the major level of the version. + * + * @return The major level of the version + */ + public int getMajor() { + return major; + } + + /** + * Returns the minor level of the version. + * + * @return The minor level of the version + */ + public int getMinor() { + return minor; + } + + /** + * Returns the patch level of the version. + * + * @return The patch level of the version + */ + public int getPatch() { + return patch; + } + + /** + * {@inheritDoc} + */ + public int compareTo(Version version) { + return (major != version.major) ? (major - version.major) : ((minor != version.minor) ? (minor - version.minor) : (patch - version.patch)); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return major + "." + minor + "." + patch; + } + } -- 2.7.4