Class JavaVersionImpl
java.lang.Object
org.sonar.java.model.JavaVersionImpl
- All Implemented Interfaces:
JavaVersion
-
Field Summary
FieldsFields inherited from interface org.sonar.plugins.java.api.JavaVersion
ENABLE_PREVIEW, SOURCE_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionJavaVersionImpl(int javaVersion) JavaVersionImpl(int javaVersion, boolean previewFeaturesEnabled) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns wether preview features are enabled or not (false by default)intasInt()get java version as integerGet the effective Java version as a String.static JavaVersionfromString(String javaVersion) static JavaVersionfromString(String javaVersion, String previewFeaturesFlag) booleanTest if java version of the project is greater than or equal to 10.booleanTest if java version of the project is greater than or equal to 12.booleanTest if java version of the project is greater than or equal to 14.booleanTest if java version of the project is greater than or equal to 15.booleanTest if java version of the project is greater than or equal to 16.booleanTest if java version of the project is greater than or equal to 17.booleanTest if java version of the project is greater than or equal to 18.booleanTest if java version of the project is greater than or equal to 19.booleanTest if java version of the project is greater than or equal to 20.booleanTest if java version of the project is greater than or equal to 21.booleanTest if java version of the project is greater than or equal to 22.booleanTest if java version of the project is greater than or equal to 23.booleanTest if java version of the project is greater than or equal to 24.booleanTest if java version of the project is not set or greater than or equal to 6.booleanTest if java version of the project is not set or greater than or equal to 7.booleanTest if java version of the project is not set greater than or equal to 8.booleanTest if java version of the project is greater than or equal to 9.booleanisNotSet()Test if java version has not been set for the analysis.booleanisSet()Test if java version has been set for the analysis.Default compatibility message with java 6Default compatibility message with java 7Default compatibility message with java 8toString()
-
Field Details
-
MAX_SUPPORTED
public static final int MAX_SUPPORTED- See Also:
-
-
Constructor Details
-
JavaVersionImpl
public JavaVersionImpl() -
JavaVersionImpl
public JavaVersionImpl(int javaVersion) -
JavaVersionImpl
public JavaVersionImpl(int javaVersion, boolean previewFeaturesEnabled)
-
-
Method Details
-
fromString
-
fromString
-
isJava6Compatible
public boolean isJava6Compatible()Description copied from interface:JavaVersionTest if java version of the project is not set or greater than or equal to 6.- Specified by:
isJava6Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 6 or not set
-
isJava7Compatible
public boolean isJava7Compatible()Description copied from interface:JavaVersionTest if java version of the project is not set or greater than or equal to 7.- Specified by:
isJava7Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 7 or not set
-
isJava8Compatible
public boolean isJava8Compatible()Description copied from interface:JavaVersionTest if java version of the project is not set greater than or equal to 8.- Specified by:
isJava8Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 8 or not set
-
isJava9Compatible
public boolean isJava9Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 9. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava9Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 9
-
isJava10Compatible
public boolean isJava10Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 10. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava10Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 10
-
isJava12Compatible
public boolean isJava12Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 12. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava12Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 12
-
isJava14Compatible
public boolean isJava14Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 14. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava14Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 14
-
isJava15Compatible
public boolean isJava15Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 15. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava15Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 15
-
isJava16Compatible
public boolean isJava16Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 16. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava16Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 16
-
isJava17Compatible
public boolean isJava17Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 17. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava17Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 17
-
isJava18Compatible
public boolean isJava18Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 18. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava18Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 18
-
isJava19Compatible
public boolean isJava19Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 19. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava19Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 19
-
isJava20Compatible
public boolean isJava20Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 20. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava20Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 120
-
isJava21Compatible
public boolean isJava21Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 21. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava21Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 21
-
isJava22Compatible
public boolean isJava22Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 22. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava22Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 22
-
isJava23Compatible
public boolean isJava23Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 23. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava23Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 23
-
isJava24Compatible
public boolean isJava24Compatible()Description copied from interface:JavaVersionTest if java version of the project is greater than or equal to 24. Remark - Contrary to other isJava*Compatible methods, this one will NOT return true if version is not set- Specified by:
isJava24Compatiblein interfaceJavaVersion- Returns:
- true if java version used is >= 24
-
java6CompatibilityMessage
Description copied from interface:JavaVersionDefault compatibility message with java 6- Specified by:
java6CompatibilityMessagein interfaceJavaVersion- Returns:
- empty string if java version is properly set, default message otherwise.
-
java7CompatibilityMessage
Description copied from interface:JavaVersionDefault compatibility message with java 7- Specified by:
java7CompatibilityMessagein interfaceJavaVersion- Returns:
- empty string if java version is properly set, default message otherwise.
-
java8CompatibilityMessage
Description copied from interface:JavaVersionDefault compatibility message with java 8- Specified by:
java8CompatibilityMessagein interfaceJavaVersion- Returns:
- empty string if java version is properly set, default message otherwise.
-
asInt
public int asInt()Description copied from interface:JavaVersionget java version as integer- Specified by:
asIntin interfaceJavaVersion- Returns:
- an int representing the java version
-
isSet
public boolean isSet()Description copied from interface:JavaVersionTest if java version has been set for the analysis.- Specified by:
isSetin interfaceJavaVersion- Returns:
- true if set, false otherwise.
-
isNotSet
public boolean isNotSet()Description copied from interface:JavaVersionTest if java version has not been set for the analysis.- Specified by:
isNotSetin interfaceJavaVersion- Returns:
- true if not set, false otherwise.
-
effectiveJavaVersionAsString
Description copied from interface:JavaVersionGet the effective Java version as a String. If no version is set, return the maximum supported version.- Specified by:
effectiveJavaVersionAsStringin interfaceJavaVersion- Returns:
- an int representing the effective java version
-
toString
-
arePreviewFeaturesEnabled
public boolean arePreviewFeaturesEnabled()Description copied from interface:JavaVersionReturns wether preview features are enabled or not (false by default)- Specified by:
arePreviewFeaturesEnabledin interfaceJavaVersion- Returns:
- true if enabled, false otherwise
-