whitespace fixups
[jSite2.git] / src / net / pterodactylus / jsite / main / Version.java
1 /*
2  * jSite2 - Version.java -
3  * Copyright © 2008 David Roden
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 package net.pterodactylus.jsite.main;
21
22 /**
23  * Container for version information.
24  *
25  * @author David Roden <bombe@freenetproject.org>
26  */
27 public class Version implements Comparable<Version> {
28
29         /** The version of the application. */
30         private static final Version VERSION = new Version(0, 99, 0);
31
32         /** The major level of the version. */
33         private final int major;
34
35         /** The minor level of the version. */
36         private final int minor;
37
38         /** The patch level of the version. */
39         private final int patch;
40
41         /**
42          * Creates a new version with the given major level and minor and patch
43          * levels set to <code>0</code>.
44          *
45          * @param major
46          *            The major level of the version
47          */
48         public Version(int major) {
49                 this(major, 0);
50         }
51
52         /**
53          * Creates a new version with the given major and minor level and the patch
54          * level set to <code>0</code>.
55          *
56          * @param major
57          *            The major level of the version
58          * @param minor
59          *            The minor level of the version
60          */
61         public Version(int major, int minor) {
62                 this(major, minor, 0);
63         }
64
65         /**
66          * Creates a new version with the given major, minor, and patch level.
67          *
68          * @param major
69          *            The major level of the version
70          * @param minor
71          *            The minor level of the version
72          * @param patch
73          *            The patch level of the version
74          */
75         public Version(int major, int minor, int patch) {
76                 this.major = major;
77                 this.minor = minor;
78                 this.patch = patch;
79         }
80
81         /**
82          * Returns the version of the application.
83          *
84          * @return The version of the application
85          */
86         public static Version getVersion() {
87                 return VERSION;
88         }
89
90         /**
91          * Returns the major level of the version.
92          *
93          * @return The major level of the version
94          */
95         public int getMajor() {
96                 return major;
97         }
98
99         /**
100          * Returns the minor level of the version.
101          *
102          * @return The minor level of the version
103          */
104         public int getMinor() {
105                 return minor;
106         }
107
108         /**
109          * Returns the patch level of the version.
110          *
111          * @return The patch level of the version
112          */
113         public int getPatch() {
114                 return patch;
115         }
116
117         /**
118          * {@inheritDoc}
119          */
120         public int compareTo(Version version) {
121                 return (major != version.major) ? (major - version.major) : ((minor != version.minor) ? (minor - version.minor) : (patch - version.patch));
122         }
123
124         /**
125          * {@inheritDoc}
126          */
127         @Override
128         public String toString() {
129                 return major + "." + minor + "." + patch;
130         }
131
132 }