Interface JavaVersion

All Known Implementing Classes:
JavaVersionImpl

@Beta public interface JavaVersion
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
    Modifier and Type
    Field
    Description
    static final String
    Flag to enable java preview features
    static final String
    Key of the java version used for sources
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns wether preview features are enabled or not (false by default)
    int
    get java version as integer
    Get 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 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 greater than or equal to 23.
    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
    Test if java version has not been set for the analysis.
    boolean
    Test if java version has been set for the analysis.
    Default compatibility message with java 6
    Default compatibility message with java 7
    Default compatibility message with java 8
  • Field Details

  • 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
    • isJava19Compatible

      boolean isJava19Compatible()
      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
      Returns:
      true if java version used is >= 19
      Since:
      SonarJava 7.19: Support of Java 19
    • isJava20Compatible

      boolean isJava20Compatible()
      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
      Returns:
      true if java version used is >= 120
      Since:
      SonarJava 8.0: Support of Java 20
    • isJava21Compatible

      boolean isJava21Compatible()
      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
      Returns:
      true if java version used is >= 21
      Since:
      SonarJava 8.0: Support of Java 21
    • isJava22Compatible

      boolean isJava22Compatible()
      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
      Returns:
      true if java version used is >= 22
      Since:
      SonarJava 8.0: Support of Java 22
    • isJava23Compatible

      boolean isJava23Compatible()
      Test 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
      Returns:
      true if java version used is >= 23
      Since:
      SonarJava 8.0: Support of Java 23
    • 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
    • arePreviewFeaturesEnabled

      boolean arePreviewFeaturesEnabled()
      Returns wether preview features are enabled or not (false by default)
      Returns:
      true if enabled, false otherwise