Skip navigation links
org.apache.myfaces.trinidad.context
Class Version
java.lang.Object
org.apache.myfaces.trinidad.context.Version
- All Implemented Interfaces:
- java.lang.Comparable<Version>
-
public final class Version
- extends java.lang.Object
- implements java.lang.Comparable<Version>
Immutable Representation of a dot-separated version. This representation allows individual sections of the version to be wild-carded and allows for comparisons between Versions with different numbers of version subsections to be compared. When comparing Versions, each version subsection is compared from left to right. If one Version doesn't have a version subsection at the current index, the value of versionPadding is used for this comparison. Version subsections with the wild-card value "*" care considered equal. The value returned by compareTo() is the value of the first non-equal version subsection or zero if all subsections match. Due to the support for wild-cards, this class has a natural ordering that is inconsistent with equals. For example, Version("5", "*").compareTo(Version("5.0", "*") == 0 Version("5", "*").equals(Version("5.0", "*") == false;
- Author:
- Blake Sullivan
| Constructor Summary |
Version(java.lang.String version)
Creates a Version instance from the dot-separated Version String using null as the padding |
Version(java.lang.String version, java.lang.String versionPadding)
Creates a Version instance from the dot-separated Version String and the versionPadding. |
| Method Summary |
int |
compareTo(Version otherVersion)
When comparing Versions, each version subsection is compared from left to right. |
boolean |
equals(java.lang.Object o)
|
int |
hashCode()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Version
public Version(java.lang.String version)
- Creates a Version instance from the dot-separated Version String using null as the padding
- Parameters:
version - The dot-separated version to represent
- Throws:
java.lang.NullPointerException - if the version is null
java.lang.IllegalArgumentException - if the version is an empty String
- See Also:
Version(String, String)
Version
public Version(java.lang.String version,
java.lang.String versionPadding)
- Creates a Version instance from the dot-separated Version String and the versionPadding.
- Parameters:
version - The dot-separated version to represent
versionPadding - The value to return for sub-version sections requested beyond the sub-version sections present in the version String
- Throws:
java.lang.NullPointerException - if version or versionPadding are null
java.lang.IllegalArgumentException - if version or versionPadding are the empty String
compareTo
public int compareTo(Version otherVersion)
- When comparing Versions, each version subsection is compared from left to right. If one Version doesn't have a version subsection at the current index, the value of versionPadding is used for this comparison. Version subsections with the wild-card value "*" care considered equal. The value returned by compareTo() is the value of the first non-equal version subsection or zero if all subsections match.
-
- Specified by:
compareTo in interface java.lang.Comparable<Version>
-
- Parameters:
otherVersion - The Version object to compare this Version Object with
- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
toString
public java.lang.String toString()
-
- Overrides:
toString in class java.lang.Object
equals
public boolean equals(java.lang.Object o)
-
- Overrides:
equals in class java.lang.Object
hashCode
public int hashCode()
-
- Overrides:
hashCode in class java.lang.Object
Skip navigation links
Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.