X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fmain%2FVersion.java;h=c405b7a42838fd0e8b61719693d0f7536fe99d22;hb=c63257e8cc0ba1a5aca9364b22171abe7279d479;hp=a98f9a7030a8fff2a9418fff92a4b35cfda3b3e1;hpb=c785ca4d7b634f79e1f30202915633aa92e4152c;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/main/Version.java b/src/net/pterodactylus/jsite/main/Version.java index a98f9a7..c405b7a 100644 --- a/src/net/pterodactylus/jsite/main/Version.java +++ b/src/net/pterodactylus/jsite/main/Version.java @@ -21,22 +21,112 @@ package net.pterodactylus.jsite.main; /** * Container for version information. - * + * * @author David Roden <bombe@freenetproject.org> - * @version $Id$ */ -public class Version { +public class Version implements Comparable { + + /** The version of the application. */ + private static final Version VERSION = new Version(0, 99, 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; + + /** + * Creates a new version with the given major level and minor and patch + * levels set to 0. + * + * @param major + * The major level of the version + */ + public Version(int major) { + this(major, 0); + } - /** The version identifier. */ - private static final String VERSION = "0.9"; + /** + * 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); + } /** - * Returns the version information. - * - * @return The version information + * 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 static final String getVersion() { + 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; + } + }