me.edwards.des.util
Class Version

java.lang.Object
  extended by me.edwards.des.util.Version

public class Version
extends java.lang.Object

Data structure representing a version for an application or class.

Created on: May 28, 2015 at 11:19:51 AM

Author:
Matthew Edwards

Field Summary
private static int[] primes
           
private  int versionHash
           
private  int[] versionNum
           
private  java.lang.String versionString
           
private  java.lang.String versionToString
           
 
Constructor Summary
Version()
          Creates new Version (Initialized as 0.0)
Version(java.lang.String version)
          Creates new Version from parsed string.
 
Method Summary
 int hashCode()
           
 boolean isEqualTo(Version v)
          Compares this version and the specified version for equality.
 boolean isNewerThan(Version v)
          Compares this version and the specified version to find the newer one.
 boolean isOlderThan(Version v)
          Compares this version and the specified version to find the older one.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

primes

private static final int[] primes

versionNum

private int[] versionNum

versionHash

private int versionHash

versionString

private java.lang.String versionString

versionToString

private java.lang.String versionToString
Constructor Detail

Version

public Version()
Creates new Version (Initialized as 0.0)


Version

public Version(java.lang.String version)
Creates new Version from parsed string.

Parameters:
version - Version in format "12.34 Version_String" with a version number first (separated with periods), a space, and a version ID string (Alpha, etc.)
Throws:
java.security.InvalidParameterException - Throws InvalidParameterException if "version" string is improperly formatted
Method Detail

isEqualTo

public boolean isEqualTo(Version v)
Compares this version and the specified version for equality.

Parameters:
v - Version to compare
Returns:
True if both versions are equal, False otherwise

isNewerThan

public boolean isNewerThan(Version v)
Compares this version and the specified version to find the newer one.

Parameters:
v - Version to compare
Returns:
True if this version is newer than the specified version, False otherwise

isOlderThan

public boolean isOlderThan(Version v)
Compares this version and the specified version to find the older one.

Parameters:
v - Version to compare
Returns:
True if this version is older than the specified version, False otherwise

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object