Package net.sourceforge.pmd.lang
Class LanguageVersion
java.lang.Object
net.sourceforge.pmd.lang.LanguageVersion
- All Implemented Interfaces:
Comparable<LanguageVersion>
Represents a version of a
Language. Language instances provide
a list of supported versions (Language.getVersions()). Individual
versions can be retrieved from their version number (Language.getVersion(String)).
Versions are used to limit some rules to operate on only a version range.
For instance, a rule that suggests eliding local variable types in Java
(replacing them with var) makes no sense if the codebase is not
using Java 10 or later. This is determined by Rule.getMinimumLanguageVersion()
and Rule.getMaximumLanguageVersion(). These should be set in the
ruleset XML (they're attributes of the <rule> element), and not
overridden.
-
Method Summary
Modifier and TypeMethodDescriptionintintcompareToVersion(String versionString) Compare this version to another version of the same language identified by the given version string.booleanReturns the language that owns this version.getName()Returns the name of this language version.Get the short name of this LanguageVersion.Get the terse name of this LanguageVersion.Returns the version string.inthashCode()toString()
-
Method Details
-
getLanguage
Returns the language that owns this version. -
getVersion
Returns the version string. This is usually a version number, e.g."1.7"or"11". This is used byLanguage.getVersion(String). -
getName
Returns the name of this language version. This is the version string prefixed with the language name.- Returns:
- The name of this LanguageVersion.
-
getShortName
Get the short name of this LanguageVersion. This is Language short name appended with the LanguageVersion version if not an empty String.- Returns:
- The short name of this LanguageVersion.
-
getTerseName
Get the terse name of this LanguageVersion. This is Language id appended with the LanguageVersion version if not an empty String.- Returns:
- The terse name of this LanguageVersion.
-
compareToVersion
Compare this version to another version of the same language identified by the given version string.- Parameters:
versionString- The version with which to compare- Throws:
IllegalArgumentException- If the argument is not a valid version string for the parent language
-
compareTo
- Specified by:
compareToin interfaceComparable<LanguageVersion>
-
equals
-
hashCode
public int hashCode() -
toString
-