Class JavaVersion
- java.lang.Object
-
- org.codehaus.plexus.languages.java.version.JavaVersion
-
- All Implemented Interfaces:
Comparable<JavaVersion>
public class JavaVersion extends Object implements Comparable<JavaVersion>
- Since:
- 1.0.0
- Author:
- Robert Scholte
- See Also:
- Java SE Naming and Versions, JEP 223: New Version-String Scheme, JEP 322: Time-Based Release Versioning
-
-
Field Summary
Fields Modifier and Type Field Description static JavaVersionJAVA_SPECIFICATION_VERSIONRepresents the System propertyjava.specification.versionstatic JavaVersionJAVA_VERSIONRepresents the System propertyjava.version
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JavaVersionasMajor()If original version starts with"1.", then remove this part from the versionintcompareTo(JavaVersion other)booleanequals(Object obj)StringgetValue()Returns the original versionStringgetValue(int groups)Returns a value respecting the nuber of groups.
If the original has more groups, the end of that value will be removed.
If the original has less groups, the value will be extended this ".0".inthashCode()booleanisAtLeast(String other)Verify if this version is at least some other versionbooleanisAtLeast(JavaVersion other)Verify if this version is at least some other versionbooleanisBefore(String other)Verify if this version is before some other versionbooleanisBefore(JavaVersion other)Verify if this version is before some other versionstatic JavaVersionparse(String s)Lazy parse the version-scheme.StringtoString()
-
-
-
Field Detail
-
JAVA_SPECIFICATION_VERSION
public static final JavaVersion JAVA_SPECIFICATION_VERSION
Represents the System propertyjava.specification.version
-
JAVA_VERSION
public static final JavaVersion JAVA_VERSION
Represents the System propertyjava.version
-
-
Method Detail
-
parse
public static JavaVersion parse(String s)
Lazy parse the version-scheme. Actual parsing is done when callingcompareTo(JavaVersion)- Parameters:
s- the version string, nevernull- Returns:
- the version wrapped in a JavadocVersion
-
compareTo
public int compareTo(JavaVersion other)
- Specified by:
compareToin interfaceComparable<JavaVersion>
-
isBefore
public boolean isBefore(JavaVersion other)
Verify if this version is before some other version- Parameters:
other- the version to compare with- Returns:
trueis this is less thanother, otherwisefalse
-
isBefore
public boolean isBefore(String other)
Verify if this version is before some other version- Parameters:
other- the version to compare with- Returns:
trueis this is less thanother, otherwisefalse
-
isAtLeast
public boolean isAtLeast(JavaVersion other)
Verify if this version is at least some other version- Parameters:
other- the version to compare with- Returns:
trueis this is greater than or equal toother, otherwisefalse
-
isAtLeast
public boolean isAtLeast(String other)
Verify if this version is at least some other version- Parameters:
other- the version to compare with- Returns:
trueis this is greater than or equal toother, otherwisefalse
-
asMajor
public JavaVersion asMajor()
If original version starts with"1.", then remove this part from the version- Returns:
- a new JavaVersion if version has to be changed, otherwise return itself
-
getValue
public String getValue()
Returns the original version- Returns:
- the raw version
-
getValue
public String getValue(int groups)
Returns a value respecting the nuber of groups.
If the original has more groups, the end of that value will be removed.
If the original has less groups, the value will be extended this ".0".
JavaVersion.parse( "1" ).getValue( 1 ) is "1" JavaVersion.parse( "1" ).getValue( 2 ) is "1.0" JavaVersion.parse( "2.1" ).getValue( 1 ) is "2" JavaVersion.parse( "2.1" ).getValue( 2 ) is "2.1"
- Parameters:
groups- number of groups to return- Returns:
- the version respecting the number of groups
-
-