Class Version
- java.lang.Object
-
- org.java.plugin.registry.Version
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Version>
public final class Version extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Version>
This class represents a plug-in version identifier.- Version:
- $Id$
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static char
SEPARATOR
Version identifier parts separator.
-
Constructor Summary
Constructors Constructor Description Version(int aMajor, int aMinor, int aBuild, java.lang.String aName)
Creates version identifier object from given parts.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Version obj)
boolean
equals(java.lang.Object obj)
int
getBuild()
int
getMajor()
int
getMinor()
java.lang.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(java.lang.String str)
Parses given string as version identifier.java.lang.String
toString()
Returns the string representation of this version identifier.
-
-
-
Field Detail
-
SEPARATOR
public static final char SEPARATOR
Version identifier parts separator.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Version
public Version(int aMajor, int aMinor, int aBuild, java.lang.String aName)
Creates version identifier object from given parts. No validation performed during object instantiation, all values become parts of version identifier as they are.- Parameters:
aMajor
- major version numberaMinor
- minor version numberaBuild
- build numberaName
- build name,null
value becomes empty string
-
-
Method Detail
-
parse
public static Version parse(java.lang.String str)
Parses given string as version identifier. All missing parts will be initialized to 0 or empty string. Parsing starts from left side of the string.- Parameters:
str
- version identifier as string- Returns:
- version identifier object
-
getBuild
public int getBuild()
- Returns:
- build number
-
getMajor
public int getMajor()
- Returns:
- major version number
-
getMinor
public int getMinor()
- Returns:
- minor version number
-
getName
public java.lang.String getName()
- Returns:
- build name
-
isGreaterOrEqualTo
public boolean isGreaterOrEqualTo(Version other)
Compares two version identifiers to see if this one is greater than or equal to the argument.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.
- Parameters:
other
- the other version identifier- Returns:
true
if this version identifier is compatible with the given version identifier, andfalse
otherwise
-
isCompatibleWith
public boolean isCompatibleWith(Version other)
Compares two version identifiers for compatibility.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.
- Parameters:
other
- the other version identifier- Returns:
true
if this version identifier is compatible with the given version identifier, andfalse
otherwise
-
isEquivalentTo
public boolean isEquivalentTo(Version other)
Compares two version identifiers for equivalency.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.
- Parameters:
other
- the other version identifier- Returns:
true
if this version identifier is equivalent to the given version identifier, andfalse
otherwise
-
isGreaterThan
public boolean isGreaterThan(Version other)
Compares two version identifiers for order using multi-decimal comparison.- Parameters:
other
- the other version identifier- Returns:
true
if this version identifier is greater than the given version identifier, andfalse
otherwise
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
toString
public java.lang.String toString()
Returns the string representation of this version identifier. The result satisfiesversion.equals(new Version(version.toString()))
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation of this version identifier
-
-