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>
28 public class Version implements Comparable<Version> {
30 /** The version of the application. */
31 private static final Version VERSION = new Version(0, 9, 0);
33 /** The major level of the version. */
34 private final int major;
36 /** The minor level of the version. */
37 private final int minor;
39 /** The patch level of the version. */
40 private final int patch;
43 * Creates a new version with the given major level and minor and patch
44 * levels set to <code>0</code>.
47 * The major level of the version
49 public Version(int major) {
54 * Creates a new version with the given major and minor level and the patch
55 * level set to <code>0</code>.
58 * The major level of the version
60 * The minor level of the version
62 public Version(int major, int minor) {
63 this(major, minor, 0);
67 * Creates a new version with the given major, minor, and patch level.
70 * The major level of the version
72 * The minor level of the version
74 * The patch level of the version
76 public Version(int major, int minor, int patch) {
83 * Returns the version of the application.
85 * @return The version of the application
87 public static Version getVersion() {
92 * Returns the major level of the version.
94 * @return The major level of the version
96 public int getMajor() {
101 * Returns the minor level of the version.
103 * @return The minor level of the version
105 public int getMinor() {
110 * Returns the patch level of the version.
112 * @return The patch level of the version
114 public int getPatch() {
121 public int compareTo(Version version) {
122 return (major != version.major) ? (major - version.major) : ((minor != version.minor) ? (minor - version.minor) : (patch - version.patch));
129 public String toString() {
130 return major + "." + minor + "." + patch;