Package org.apache.commons.lang3
Enum Class JavaVersion
- All Implemented Interfaces:
Serializable
,Comparable<JavaVersion>
,Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe Java version reported by Android.Java 1.1.Java 1.2.Java 1.3.Java 1.4.Java 1.5.Java 1.6.Java 1.7.Java 1.8.Deprecated.Java 10.Java 11.Java 12.Java 13.Java 14.Java 15.Java 16.Java 17.Java 9.The most recent java version. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
atLeast
(JavaVersion requiredVersion) Whether this version of Java is at least the version of Java passed in.boolean
atMost
(JavaVersion requiredVersion) Whether this version of Java is at most the version of Java passed in.(package private) static JavaVersion
Transforms the given string with a Java version number to the corresponding constant of this enumeration class.(package private) static JavaVersion
getJavaVersion
(String nom) Transforms the given string with a Java version number to the corresponding constant of this enumeration class.private static float
Gets the Java Version from the system or 99.0 if thejava.specification.version
system property is not set.private static float
toFloatVersion
(String value) Parses a float value from a String.toString()
The string value is overridden to return the standard name.static JavaVersion
Returns the enum constant of this class with the specified name.static JavaVersion[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
JAVA_0_9
The Java version reported by Android. This is not an official Java version number. -
JAVA_1_1
Java 1.1. -
JAVA_1_2
Java 1.2. -
JAVA_1_3
Java 1.3. -
JAVA_1_4
Java 1.4. -
JAVA_1_5
Java 1.5. -
JAVA_1_6
Java 1.6. -
JAVA_1_7
Java 1.7. -
JAVA_1_8
Java 1.8. -
JAVA_1_9
Deprecated.As of release 3.5, replaced byJAVA_9
Java 1.9. -
JAVA_9
Java 9.- Since:
- 3.5
-
JAVA_10
Java 10.- Since:
- 3.7
-
JAVA_11
Java 11.- Since:
- 3.8
-
JAVA_12
Java 12.- Since:
- 3.9
-
JAVA_13
Java 13.- Since:
- 3.9
-
JAVA_14
Java 14.- Since:
- 3.11
-
JAVA_15
Java 15.- Since:
- 3.11
-
JAVA_16
Java 16.- Since:
- 3.11
-
JAVA_17
Java 17.- Since:
- 3.12.0
-
JAVA_RECENT
The most recent java version. Mainly introduced to avoid to break when a new version of Java is used.
-
-
Field Details
-
value
private final float valueThe float value. -
name
The standard name.
-
-
Constructor Details
-
JavaVersion
Constructor.- Parameters:
value
- the float valuename
- the standard name, not null
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-
atLeast
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
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
-
getJavaVersion
Transforms the given string with a Java version number to the corresponding constant of this enumeration class. This method is used internally.- Parameters:
nom
- the Java version as string- Returns:
- the corresponding enumeration constant or null if the version is unknown
-
get
Transforms the given string with a Java version number to the corresponding constant of this enumeration class. This method is used internally.- Parameters:
versionStr
- the Java version as string- Returns:
- the corresponding enumeration constant or null if the version is unknown
-
toString
The string value is overridden to return the standard name.
For example,
"1.5"
.- Overrides:
toString
in classEnum<JavaVersion>
- Returns:
- the name, not null
-
maxVersion
private static float maxVersion()Gets the Java Version from the system or 99.0 if thejava.specification.version
system property is not set.- Returns:
- the value of
java.specification.version
system property or 99.0 if it is not set.
-
toFloatVersion
Parses a float value from a String.- Parameters:
value
- the String to parse.- Returns:
- the float value represented by the string or -1 if the given String can not be parsed.
-
JAVA_9