Package org.jboss.modules
Class Version
- java.lang.Object
-
- org.jboss.modules.Version
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Version>
public final class Version extends java.lang.Object implements java.lang.Comparable<Version>, java.io.Serializable
A version for a module. Versions are series of letters and digits, optionally divided by separator characters, which include.,-,+, and_. The transition between letter and digit (or vice-versa) is also considered to be an invisible separator.Versions may be compared, sorted, used as hash keys, and iterated.
- Author:
- David M. Lloyd
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classVersion.IteratorAn iterator over the parts of a version.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Version that)Compares this module version to another module version.booleanequals(java.lang.Object ob)Tests this module version for equality with the given object.inthashCode()Computes a hash code for this module version.Version.Iteratoriterator()Construct a new iterator over the parts of this version string.static Versionparse(java.lang.String v)Parses the given string as a version string.java.lang.StringtoString()Returns the normalized string representation of this version.
-
-
-
Method Detail
-
parse
public static Version parse(java.lang.String v)
Parses the given string as a version string.- Parameters:
v- The string to parse- Returns:
- The resulting
Version - Throws:
java.lang.IllegalArgumentException- Ifvisnull, an empty string, or cannot be parsed as a version string
-
iterator
public Version.Iterator iterator()
Construct a new iterator over the parts of this version string.- Returns:
- the iterator
-
compareTo
public int compareTo(Version that)
Compares this module version to another module version. Module versions are compared as described in the class description.- Specified by:
compareToin interfacejava.lang.Comparable<Version>- Parameters:
that- The module version to compare- Returns:
- A negative integer, zero, or a positive integer as this module version is less than, equal to, or greater than the given module version
-
equals
public boolean equals(java.lang.Object ob)
Tests this module version for equality with the given object.If the given object is not a
Versionthen this method returnsfalse. Two module version are equal if their corresponding components are equal.This method satisfies the general contract of the
Object.equalsmethod.- Overrides:
equalsin classjava.lang.Object- Parameters:
ob- the object to which this object is to be compared- Returns:
trueif, and only if, the given object is a module reference that is equal to this module reference
-
hashCode
public int hashCode()
Computes a hash code for this module version.The hash code is based upon the components of the version and satisfies the general contract of the
Object.hashCodemethod.- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hash-code value for this module version
-
toString
public java.lang.String toString()
Returns the normalized string representation of this version.- Overrides:
toStringin classjava.lang.Object- Returns:
- The normalized string.
-
-