Package org.sonar.plugins.java.api
Interface JavaVersion
- All Known Implementing Classes:
JavaVersionImpl
Represents the java version used by the project under analysis.
Designed to be used by checks to determine if they should report issue depending on java version.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
asInt()
get java version as integerGet the effective Java version as a String.boolean
Test if java version of the project is greater than or equal to 10.boolean
Test if java version of the project is greater than or equal to 12.boolean
Test if java version of the project is greater than or equal to 14.boolean
Test if java version of the project is greater than or equal to 15.boolean
Test if java version of the project is greater than or equal to 16.boolean
Test if java version of the project is greater than or equal to 17.boolean
Test if java version of the project is greater than or equal to 18.boolean
Test if java version of the project is not set or greater than or equal to 6.boolean
Test if java version of the project is not set or greater than or equal to 7.boolean
Test if java version of the project is not set greater than or equal to 8.boolean
Test if java version of the project is greater than or equal to 9.boolean
isNotSet()
Test if java version has not been set for the analysis.boolean
isSet()
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 8
-
Field Details
-
SOURCE_VERSION
Key of the java version used for sources- See Also:
-
-
Method Details
-
isJava6Compatible
boolean isJava6Compatible()Test if java version of the project is not set or greater than or equal to 6.- Returns:
- true if java version used is >= 6 or not set
-
isJava7Compatible
boolean isJava7Compatible()Test if java version of the project is not set or greater than or equal to 7.- Returns:
- true if java version used is >= 7 or not set
-
isJava8Compatible
boolean isJava8Compatible()Test if java version of the project is not set greater than or equal to 8.- Returns:
- true if java version used is >= 8 or not set
-
isJava9Compatible
boolean isJava9Compatible()Test 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- Returns:
- true if java version used is >= 9
- Since:
- SonarJava 6.15
-
isJava10Compatible
boolean isJava10Compatible()Test 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- Returns:
- true if java version used is >= 10
- Since:
- SonarJava 6.15
-
isJava12Compatible
boolean isJava12Compatible()Test 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- Returns:
- true if java version used is >= 12
- Since:
- SonarJava 5.12: Support of Java 12
-
isJava14Compatible
boolean isJava14Compatible()Test 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- Returns:
- true if java version used is >= 14
- Since:
- SonarJava 6.15
-
isJava15Compatible
boolean isJava15Compatible()Test 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- Returns:
- true if java version used is >= 15
- Since:
- SonarJava 6.12: Support of Java 15
-
isJava16Compatible
boolean isJava16Compatible()Test 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- Returns:
- true if java version used is >= 16
- Since:
- SonarJava 7.1: Support of Java 16
-
isJava17Compatible
boolean isJava17Compatible()Test 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- Returns:
- true if java version used is >= 17
- Since:
- SonarJava 7.14: Support of Java 18
-
isJava18Compatible
boolean isJava18Compatible()Test 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- Returns:
- true if java version used is >= 18
- Since:
- SonarJava 7.14: Support of Java 18
-
asInt
int asInt()get java version as integer- Returns:
- an int representing the java version
-
isSet
boolean isSet()Test if java version has been set for the analysis.- Returns:
- true if set, false otherwise.
-
isNotSet
boolean isNotSet()Test if java version has not been set for the analysis.- Returns:
- true if not set, false otherwise.
-
java6CompatibilityMessage
String java6CompatibilityMessage()Default compatibility message with java 6- Returns:
- empty string if java version is properly set, default message otherwise.
-
java7CompatibilityMessage
String java7CompatibilityMessage()Default compatibility message with java 7- Returns:
- empty string if java version is properly set, default message otherwise.
-
java8CompatibilityMessage
String java8CompatibilityMessage()Default compatibility message with java 8- Returns:
- empty string if java version is properly set, default message otherwise.
-
effectiveJavaVersionAsString
String effectiveJavaVersionAsString()Get the effective Java version as a String. If no version is set, return the maximum supported version.- Returns:
- an int representing the effective java version
-