Package org.sonar.java.model
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 TypeMethodDescriptionboolean
Returns wether preview features are enabled or not (false by default)int
asInt()
get java version as integerGet the effective Java version as a String.static JavaVersion
fromString
(String javaVersion) static JavaVersion
fromStrings
(String javaVersion, String previewFeaturesFlag) 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 greater than or equal to 19.boolean
Test if java version of the project is greater than or equal to 20.boolean
Test if java version of the project is greater than or equal to 21.boolean
Test if java version of the project is greater than or equal to 22.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 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
-
fromStrings
-
isJava6Compatible
public boolean isJava6Compatible()Description copied from interface:JavaVersion
Test if java version of the project is not set or greater than or equal to 6.- Specified by:
isJava6Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 6 or not set
-
isJava7Compatible
public boolean isJava7Compatible()Description copied from interface:JavaVersion
Test if java version of the project is not set or greater than or equal to 7.- Specified by:
isJava7Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 7 or not set
-
isJava8Compatible
public boolean isJava8Compatible()Description copied from interface:JavaVersion
Test if java version of the project is not set greater than or equal to 8.- Specified by:
isJava8Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 8 or not set
-
isJava9Compatible
public boolean isJava9Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava9Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 9
-
isJava10Compatible
public boolean isJava10Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava10Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 10
-
isJava12Compatible
public boolean isJava12Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava12Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 12
-
isJava14Compatible
public boolean isJava14Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava14Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 14
-
isJava15Compatible
public boolean isJava15Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava15Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 15
-
isJava16Compatible
public boolean isJava16Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava16Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 16
-
isJava17Compatible
public boolean isJava17Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava17Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 17
-
isJava18Compatible
public boolean isJava18Compatible()Description copied from interface:JavaVersion
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- Specified by:
isJava18Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 18
-
isJava19Compatible
public boolean isJava19Compatible()Description copied from interface:JavaVersion
Test 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:
isJava19Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 19
-
isJava20Compatible
public boolean isJava20Compatible()Description copied from interface:JavaVersion
Test 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:
isJava20Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 120
-
isJava21Compatible
public boolean isJava21Compatible()Description copied from interface:JavaVersion
Test 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:
isJava21Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 21
-
isJava22Compatible
public boolean isJava22Compatible()Description copied from interface:JavaVersion
Test 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:
isJava22Compatible
in interfaceJavaVersion
- Returns:
- true if java version used is >= 22
-
java6CompatibilityMessage
Description copied from interface:JavaVersion
Default compatibility message with java 6- Specified by:
java6CompatibilityMessage
in interfaceJavaVersion
- Returns:
- empty string if java version is properly set, default message otherwise.
-
java7CompatibilityMessage
Description copied from interface:JavaVersion
Default compatibility message with java 7- Specified by:
java7CompatibilityMessage
in interfaceJavaVersion
- Returns:
- empty string if java version is properly set, default message otherwise.
-
java8CompatibilityMessage
Description copied from interface:JavaVersion
Default compatibility message with java 8- Specified by:
java8CompatibilityMessage
in interfaceJavaVersion
- Returns:
- empty string if java version is properly set, default message otherwise.
-
asInt
public int asInt()Description copied from interface:JavaVersion
get java version as integer- Specified by:
asInt
in interfaceJavaVersion
- Returns:
- an int representing the java version
-
isSet
public boolean isSet()Description copied from interface:JavaVersion
Test if java version has been set for the analysis.- Specified by:
isSet
in interfaceJavaVersion
- Returns:
- true if set, false otherwise.
-
isNotSet
public boolean isNotSet()Description copied from interface:JavaVersion
Test if java version has not been set for the analysis.- Specified by:
isNotSet
in interfaceJavaVersion
- Returns:
- true if not set, false otherwise.
-
effectiveJavaVersionAsString
Description copied from interface:JavaVersion
Get the effective Java version as a String. If no version is set, return the maximum supported version.- Specified by:
effectiveJavaVersionAsString
in interfaceJavaVersion
- Returns:
- an int representing the effective java version
-
toString
-
arePreviewFeaturesEnabled
public boolean arePreviewFeaturesEnabled()Description copied from interface:JavaVersion
Returns wether preview features are enabled or not (false by default)- Specified by:
arePreviewFeaturesEnabled
in interfaceJavaVersion
- Returns:
- true if enabled, false otherwise
-