TypecastParenPad
Since Checkstyle 3.2
Description
Checks the policy on the padding of parentheses for typecasts. That is, whether a space is required after a left parenthesis and before a right parenthesis, or such spaces are forbidden.
Properties
Examples
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="TypecastParenPad"/>
</module>
</module>
Example:
class Example1 {
double d = 3.14;
int a = ( int ) d; // 2 violations
int b = (int ) d; // violation 'preceded with whitespace'
int c = ( int) d; // violation 'followed by whitespace'
int e = (int) d;
double d2 = 9.8;
int f = (int) d2;
int g = ( int ) d2; // 2 violations
}
To configure the check to require spaces:
<module name="Checker">
<module name="TreeWalker">
<module name="TypecastParenPad">
<property name="option" value="space"/>
</module>
</module>
</module>
Example:
class Example2 {
double d = 3.14;
int a = ( int ) d;
int b = (int ) d; // violation 'not followed by whitespace'
int c = ( int) d; // violation 'not preceded with whitespace'
int e = (int) d; // 2 violations
double d2 = 9.8;
int f = (int) d2; // 2 violations
int g = ( int ) d2;
}
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.
Fully Qualified Name
com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck
Use this fully qualified class name in configuration when an exact class reference is required.






