2 * jSite2 - Version.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.jsite.main;
23 * Container for version information.
25 * @author David Roden <bombe@freenetproject.org>
27 public class Version implements Comparable<Version> {
29 /** The version of the application. */
30 private static final Version VERSION = new Version(0, 99, 0);
32 /** The major level of the version. */
33 private final int major;
35 /** The minor level of the version. */
36 private final int minor;
38 /** The patch level of the version. */
39 private final int patch;
42 * Creates a new version with the given major level and minor and patch
43 * levels set to <code>0</code>.
46 * The major level of the version
48 public Version(int major) {
53 * Creates a new version with the given major and minor level and the patch
54 * level set to <code>0</code>.
57 * The major level of the version
59 * The minor level of the version
61 public Version(int major, int minor) {
62 this(major, minor, 0);
66 * Creates a new version with the given major, minor, and patch level.
69 * The major level of the version
71 * The minor level of the version
73 * The patch level of the version
75 public Version(int major, int minor, int patch) {
82 * Returns the version of the application.
84 * @return The version of the application
86 public static Version getVersion() {
91 * Returns the major level of the version.
93 * @return The major level of the version
95 public int getMajor() {
100 * Returns the minor level of the version.
102 * @return The minor level of the version
104 public int getMinor() {
109 * Returns the patch level of the version.
111 * @return The patch level of the version
113 public int getPatch() {
120 public int compareTo(Version version) {
121 return (major != version.major) ? (major - version.major) : ((minor != version.minor) ? (minor - version.minor) : (patch - version.patch));
128 public String toString() {
129 return major + "." + minor + "." + patch;