Enum JavaVersion

java.lang.Object
java.lang.Enum<JavaVersion>
org.apache.commons.lang3.JavaVersion
All Implemented Interfaces:
Serializable, Comparable<JavaVersion>

public enum JavaVersion extends Enum<JavaVersion>
An enum representing all the versions of the Java specification. This is intended to mirror available values from the java.specification.version System property.
Since:
3.0
  • Enum Constant Details

  • Method Details

    • values

      public static JavaVersion[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static JavaVersion valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • atLeast

      public boolean atLeast(JavaVersion requiredVersion)
      Tests whether this version of Java is at least the version of Java passed in.

      For example:
      myVersion.atLeast(JavaVersion.JAVA_1_4)

      Parameters:
      requiredVersion - the version to check against, not null
      Returns:
      true if this version is equal to or greater than the specified version
    • atMost

      public boolean atMost(JavaVersion requiredVersion)
      Tests whether this version of Java is at most the version of Java passed in.

      For example:
      myVersion.atMost(JavaVersion.JAVA_1_4)

      Parameters:
      requiredVersion - the version to check against, not null
      Returns:
      true if this version is equal to or greater than the specified version
      Since:
      3.9
    • toString

      public String toString()
      The string value is overridden to return the standard name.

      For example, "1.5".

      Overrides:
      toString in class Enum<JavaVersion>
      Returns:
      the name, not null