public final class Version extends Object implements Serializable, Comparable<Version>
Modifier and Type | Field and Description |
---|---|
static char |
SEPARATOR
Version identifier parts separator.
|
Constructor and Description |
---|
Version(int aMajor,
int aMinor,
int aBuild,
String aName)
Creates version identifier object from given parts.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version obj) |
boolean |
equals(Object obj) |
int |
getBuild() |
int |
getMajor() |
int |
getMinor() |
String |
getName() |
int |
hashCode() |
boolean |
isCompatibleWith(Version other)
Compares two version identifiers for compatibility.
|
boolean |
isEquivalentTo(Version other)
Compares two version identifiers for equivalency.
|
boolean |
isGreaterOrEqualTo(Version other)
Compares two version identifiers to see if this one is
greater than or equal to the argument.
|
boolean |
isGreaterThan(Version other)
Compares two version identifiers for order using multi-decimal
comparison.
|
static Version |
parse(String str)
Parses given string as version identifier.
|
String |
toString()
Returns the string representation of this version identifier.
|
public static final char SEPARATOR
public Version(int aMajor, int aMinor, int aBuild, String aName)
aMajor
- major version numberaMinor
- minor version numberaBuild
- build numberaName
- build name, null
value becomes empty stringpublic static Version parse(String str)
str
- version identifier as stringpublic int getBuild()
public int getMajor()
public int getMinor()
public String getName()
public boolean isGreaterOrEqualTo(Version other)
A version identifier is considered to be greater than or equal if its major component is greater than the argument major component, or the major components are equal and its minor component is greater than the argument minor component, or the major and minor components are equal and its build component is greater than the argument build component, or all components are equal.
other
- the other version identifiertrue
if this version identifier
is compatible with the given version identifier, and
false
otherwisepublic boolean isCompatibleWith(Version other)
A version identifier is considered to be compatible if its major component equals to the argument major component, and its minor component is greater than or equal to the argument minor component. If the minor components are equal, than the build component of the version identifier must be greater than or equal to the build component of the argument identifier.
other
- the other version identifiertrue
if this version identifier
is compatible with the given version identifier, and
false
otherwisepublic boolean isEquivalentTo(Version other)
Two version identifiers are considered to be equivalent if their major and minor components equal and are at least at the same build level as the argument.
other
- the other version identifiertrue
if this version identifier
is equivalent to the given version identifier, and
false
otherwisepublic boolean isGreaterThan(Version other)
other
- the other version identifiertrue
if this version identifier
is greater than the given version identifier, and
false
otherwisepublic int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public String toString()
version.equals(new Version(version.toString()))
.public int compareTo(Version obj)
compareTo
in interface Comparable<Version>
obj
- version to compare this instance withComparable.compareTo(java.lang.Object)
Copyright © 2016. All Rights Reserved.