RecordComponentName
Since Checkstyle 8.40
Description
Checks that record component names conform to a specified pattern.
Properties
name | description | type | default value | since |
---|---|---|---|---|
format | Sets the pattern to match valid identifiers. | Pattern | "^[a-z][a-zA-Z0-9]*$" |
8.40 |
Examples
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="RecordComponentName"/>
</module>
</module>
Example:
class Example1 {
record Rec1(int other) {}
record Rec2(String Values) {} // violation, Name must match '^[a-z][a-zA-Z0-9]*$'
record Rec3(double myNumber) {}
}
An example of how to configure the check for names that are only letters in lowercase:
Configuration:
<module name="Checker">
<module name="TreeWalker">
<module name="RecordComponentName">
<property name="format" value="^[a-z]+$"/>
</module>
</module>
</module>
Example:
class Example2 {
record Rec1(int other) {}
record Rec2(String Values) {} // violation, Name must match '^[a-z]+$'
record Rec3(double myNumber) {} // violation, Name must match '^[a-z]+$'
}
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Package
com.puppycrawl.tools.checkstyle.checks.naming