Package com.helger.commons.system
Enum EJavaVersion
- java.lang.Object
-
- java.lang.Enum<EJavaVersion>
-
- com.helger.commons.system.EJavaVersion
-
- All Implemented Interfaces:
Serializable,Comparable<EJavaVersion>
public enum EJavaVersion extends Enum<EJavaVersion>
Enumeration for representing the current Java JDK version.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EJavaVersiongetCurrentVersion()static EJavaVersiongetFromMajorAndMinor(int nMajor, int nMinor)Get the matching Java version from a class version.static EJavaVersiongetFromVersionNumber(double dVersion)booleanisCurrentVersion()protected booleanisMatchingVersion(double dVersion)booleanisNewerOrEqualsThan(EJavaVersion eJavaVersion)Check if this java version is newer or equals than the passed versionbooleanisOlderOrEqualsThan(EJavaVersion eJavaVersion)Check if this java version is older or equals than the passed versionbooleanisSupportedVersion()static EJavaVersionvalueOf(String name)Returns the enum constant of this type with the specified name.static EJavaVersion[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UNKNOWN
public static final EJavaVersion UNKNOWN
-
JDK_1_1
public static final EJavaVersion JDK_1_1
-
JDK_1_2
public static final EJavaVersion JDK_1_2
-
JDK_1_3
public static final EJavaVersion JDK_1_3
-
JDK_1_4
public static final EJavaVersion JDK_1_4
-
JDK_1_5
public static final EJavaVersion JDK_1_5
-
JDK_1_6
public static final EJavaVersion JDK_1_6
-
JDK_1_7
public static final EJavaVersion JDK_1_7
-
JDK_1_8
public static final EJavaVersion JDK_1_8
-
JDK_9
public static final EJavaVersion JDK_9
-
JDK_10
public static final EJavaVersion JDK_10
-
JDK_11
public static final EJavaVersion JDK_11
-
JDK_12
public static final EJavaVersion JDK_12
-
JDK_13
public static final EJavaVersion JDK_13
-
JDK_14
public static final EJavaVersion JDK_14
-
JDK_15
public static final EJavaVersion JDK_15
-
JDK_16
public static final EJavaVersion JDK_16
-
JDK_17
public static final EJavaVersion JDK_17
-
JDK_18
public static final EJavaVersion JDK_18
-
JDK_19
public static final EJavaVersion JDK_19
-
JDK_20
public static final EJavaVersion JDK_20
-
-
Method Detail
-
values
public static EJavaVersion[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (EJavaVersion c : EJavaVersion.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EJavaVersion 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 nameNullPointerException- if the argument is null
-
isMatchingVersion
protected boolean isMatchingVersion(double dVersion)
-
isCurrentVersion
public boolean isCurrentVersion()
- Returns:
trueif this is the current version,falseotherwise
-
isSupportedVersion
public boolean isSupportedVersion()
- Returns:
trueif this Java version is supported by the current Java Version. It is expected that all versions are backward compatible.
-
isOlderOrEqualsThan
public boolean isOlderOrEqualsThan(@Nonnull EJavaVersion eJavaVersion)
Check if this java version is older or equals than the passed version- Parameters:
eJavaVersion- the Java version to be checked. May not benull.- Returns:
trueif this Java version is old or equal than the passed version.
-
isNewerOrEqualsThan
public boolean isNewerOrEqualsThan(@Nonnull EJavaVersion eJavaVersion)
Check if this java version is newer or equals than the passed version- Parameters:
eJavaVersion- the Java version to be checked. May not benull.- Returns:
trueif this Java version is newer or equal than the passed version.
-
getCurrentVersion
@Nonnull public static EJavaVersion getCurrentVersion()
- Returns:
- The current Java version. If the Java version could not be
determined,
UNKNOWNis returned and nevernull.
-
getFromMajorAndMinor
@Nonnull public static EJavaVersion getFromMajorAndMinor(int nMajor, int nMinor)
Get the matching Java version from a class version.- Parameters:
nMajor- Major version numbernMinor- Minor version number- Returns:
UNKNOWNif the version could not be determined.
-
getFromVersionNumber
@Nonnull public static EJavaVersion getFromVersionNumber(double dVersion)
-
-