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:
  • Field Details Link icon

    • JAVA_SPECIFICATION_VERSION Link icon

      public static final JavaVersion JAVA_SPECIFICATION_VERSION
      Represents the System property java.specification.version
    • JAVA_VERSION Link icon

      public static final JavaVersion JAVA_VERSION
      Represents the System property java.version
  • Method Details Link icon

    • parse Link icon

      public static JavaVersion parse(String s)
      Lazy parse the version-scheme. Actual parsing is done when calling compareTo(JavaVersion)
      Parameters:
      s - the version string, never null
      Returns:
      the version wrapped in a JavaVersion
    • compareTo Link icon

      public int compareTo(JavaVersion other)
      Specified by:
      compareTo in interface Comparable<JavaVersion>
    • isBefore Link icon

      public boolean isBefore(JavaVersion other)
      Verify if this version is before some other version
      Parameters:
      other - the version to compare with
      Returns:
      true is this is less than other, otherwise false
    • isBefore Link icon

      public boolean isBefore(String other)
      Verify if this version is before some other version
      Parameters:
      other - the version to compare with
      Returns:
      true is this is less than other, otherwise false
    • isAtLeast Link icon

      public boolean isAtLeast(JavaVersion other)
      Verify if this version is at least some other version
      Parameters:
      other - the version to compare with
      Returns:
      true is this is greater than or equal to other, otherwise false
    • isAtLeast Link icon

      public boolean isAtLeast(String other)
      Verify if this version is at least some other version
      Parameters:
      other - the version to compare with
      Returns:
      true is this is greater than or equal to other, otherwise false
    • asMajor Link icon

      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 Link icon

      public String getValue()
      Returns the original version
      Returns:
      the raw version
    • getValue Link icon

      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
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object