info.aduna.app
Class AppVersion

java.lang.Object
  extended by info.aduna.app.AppVersion
All Implemented Interfaces:
Comparable<AppVersion>

public class AppVersion
extends Object
implements Comparable<AppVersion>

A product version in Aduna's version format (i.e. major.minor-modifier). Where major stands for the major version number of the release, minor is the minor version number, and modifier is a modifier for the release, e.g. beta1 or RC1. Combined, this results in versions like 2.0 and 4.1-beta1.


Constructor Summary
AppVersion()
          Construct an uninitialized AppVersion.
AppVersion(int major, int minor)
          Creates a new major.minor version number, e.g.
AppVersion(int major, int minor, int micro)
          Creates a new major.minor.micro version number, e.g.
AppVersion(int major, int minor, int micro, String modifier)
          Creates a new major.minor.micro-modifier version number, e.g.
AppVersion(int major, int minor, String modifier)
          Creates a new major.minor-modifier version number, e.g.
 
Method Summary
 int compareTo(AppVersion other)
          Compares two version numbers according to their major, minor and micro version numbers, ordering from oldest to newests version.
 boolean equals(Object other)
           
 int getMajor()
          Gets the version's major version number.
 int getMicro()
          Gets the version's micro version number.
 int getMinor()
          Gets the version's minor version number.
 String getModifier()
          Gets the version's release modifier part.
 int hashCode()
           
 boolean newerThan(AppVersion other)
          Checks if this version is newer than the specified version, according to the result of compareTo(AppVersion).
 boolean olderThan(AppVersion other)
          Checks if this version is older than the specified version, according to the result of compareTo(AppVersion).
static AppVersion parse(String versionString)
          Parses a version string into a Version object.
 void setMajor(int major)
           
 void setMicro(int micro)
           
 void setMinor(int minor)
           
 void setModifier(String modifier)
           
 String toString()
          Returns the string represention of this version.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AppVersion

public AppVersion()
Construct an uninitialized AppVersion.


AppVersion

public AppVersion(int major,
                  int minor)
Creates a new major.minor version number, e.g. 1.0.


AppVersion

public AppVersion(int major,
                  int minor,
                  int micro)
Creates a new major.minor.micro version number, e.g. 1.0.1.


AppVersion

public AppVersion(int major,
                  int minor,
                  String modifier)
Creates a new major.minor-modifier version number, e.g. 1.0-beta1.


AppVersion

public AppVersion(int major,
                  int minor,
                  int micro,
                  String modifier)
Creates a new major.minor.micro-modifier version number, e.g. 1.0.1-SNAPSHOT.

Method Detail

getMajor

public int getMajor()
Gets the version's major version number.


setMajor

public void setMajor(int major)

getMinor

public int getMinor()
Gets the version's minor version number.


setMinor

public void setMinor(int minor)

getMicro

public int getMicro()
Gets the version's micro version number.


setMicro

public void setMicro(int micro)

getModifier

public String getModifier()
Gets the version's release modifier part.


setModifier

public void setModifier(String modifier)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

olderThan

public boolean olderThan(AppVersion other)
Checks if this version is older than the specified version, according to the result of compareTo(AppVersion).


newerThan

public boolean newerThan(AppVersion other)
Checks if this version is newer than the specified version, according to the result of compareTo(AppVersion).


compareTo

public int compareTo(AppVersion other)
Compares two version numbers according to their major, minor and micro version numbers, ordering from oldest to newests version. If all three version numbers are equal then their modifiers are compared lexicographically (based on the Unicode value of each character), ignoring case. Versions without a modifier are considered to be the "final" versions and come after otherwise equal versions with a modifier.

Specified by:
compareTo in interface Comparable<AppVersion>
Returns:
0 if both versions are equal, a negative number if this version is older than other, or a positive number otherwise.

parse

public static AppVersion parse(String versionString)
Parses a version string into a Version object.

Parameters:
versionString - A version string, e.g. 1.0.1 or 1.0-beta1.
Returns:
The parsed Version.
Throws:
NumberFormatException - If versionString could not be parsed to a version.

toString

public String toString()
Returns the string represention of this version.

Overrides:
toString in class Object


Copyright © 2001-2012 Aduna. All Rights Reserved.