208 lines
6.0 KiB
HTML
208 lines
6.0 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title>Modifier Checks</title>
|
|
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
|
|
</head>
|
|
|
|
<body>
|
|
<!-- The header -->
|
|
<table border="0" width="100%" summary="header layout">
|
|
<tr>
|
|
<td><h1>Modifier Checks</h1></td>
|
|
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
|
|
</tr>
|
|
</table>
|
|
<!-- content -->
|
|
<table border="0" width="100%" cellpadding="5" summary="body layout">
|
|
<tr>
|
|
<!--Left menu-->
|
|
<td class="menu" valign="top">
|
|
<ul>
|
|
<li>
|
|
<a href="#Modifier">Modifier</a>
|
|
</li>
|
|
<li>
|
|
<a href="#RedundantModifier">RedundantModifier</a>
|
|
</li>
|
|
<li>
|
|
<a href="#VisibilityModifier">VisibilityModifier</a>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
<!--Content-->
|
|
<td class="content" valign="top" align="left"><a name="Modifier"></a> <h2>Modifier</h2>
|
|
<h4>Description</h4>
|
|
|
|
<p class="body">
|
|
Checks that the order of modifiers conforms to the suggestions in the <a href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html">Java
|
|
Language specification, sections 8.1.1, 8.3.1 and 8.4.3</a>. The correct order
|
|
is:
|
|
</p>
|
|
|
|
<ol class="body">
|
|
<li>
|
|
<span class="code">public</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">protected</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">private</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">abstract</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">static</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">final</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">transient</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">volatile</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">synchronized</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">native</span>
|
|
</li>
|
|
<li>
|
|
<span class="code">strictfp</span>
|
|
</li>
|
|
</ol>
|
|
|
|
<h4>Example</h4>
|
|
<p class="body">
|
|
To configure the check:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="Modifier"/>
|
|
</pre>
|
|
|
|
<h4>Package</h4>
|
|
<p class="body">
|
|
com.puppycrawl.tools.checkstyle.checks
|
|
</p>
|
|
|
|
<h4>Parent Module</h4>
|
|
<p class="body">
|
|
TreeWalker
|
|
</p>
|
|
<a name="RedundantModifier"></a><h2>RedundantModifier</h2>
|
|
|
|
<p class="body">
|
|
Checks that method declarations in interfaces include neither the <span class="code">
|
|
public</span> modifier nor the <span class="code">abstract</span> modifier (see
|
|
the <a
|
|
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
|
|
Language specification, section 9.4</a>).
|
|
</p>
|
|
<h4>Example</h4>
|
|
<p class="body">
|
|
To configure the check:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="RedundantModifier"/>
|
|
</pre>
|
|
<h4>Package</h4>
|
|
<p class="body">
|
|
com.puppycrawl.tools.checkstyle.checks
|
|
</p>
|
|
<h4>Parent Module</h4>
|
|
<p class="body">
|
|
TreeWalker
|
|
</p>
|
|
|
|
|
|
<a name="VisibilityModifier"></a><h2>VisibilityModifier</h2>
|
|
<p class="body">
|
|
Checks visibility of class members. Only static final members may be public;
|
|
other class members must be private unless property <span class="code">
|
|
protectedAllowed</span> or <span class="code">packageAllowed</span> is set.
|
|
</p>
|
|
<p class="body">
|
|
Public members are not flagged if they are in the set of allowed public members
|
|
(contains <span class="code">"serialVersionUID"</span> by default), or if the
|
|
name matches the public member regular expression.
|
|
</p>
|
|
<p class="body">
|
|
Rationale: Enforce encapsulation.
|
|
</p>
|
|
|
|
|
|
<h4>Properties</h4>
|
|
<table width="100%" border="1" cellpadding="5" class="body">
|
|
<tr class="header">
|
|
<th>name</th>
|
|
<th>description</th>
|
|
<th>type</th>
|
|
<th>default value</th>
|
|
</tr>
|
|
<tr>
|
|
<td>packageAllowed</td>
|
|
<td>whether package visible members are allowed</td>
|
|
<td><a href="property_types.html#boolean">boolean</a></td>
|
|
<td><span class="default">false</span></td>
|
|
</tr>
|
|
<tr>
|
|
<td>protectedAllowed</td>
|
|
<td>whether protected members are allowed</td>
|
|
<td><a href="property_types.html#boolean">boolean</a></td>
|
|
<td><span class="default">false</span></td>
|
|
</tr>
|
|
<tr>
|
|
<td>publicMemberPattern</td>
|
|
<td>pattern for public members that should be ignored</td>
|
|
<td><a href="property_types.html#regexp">regular expression</a></td>
|
|
<td><span class="default">^f[A-Z][a-zA-Z0-9]*$</span></td>
|
|
</tr>
|
|
</table>
|
|
<h4>Examples</h4>
|
|
<p class="body">
|
|
To configure the check:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="VisibilityModifier"/>
|
|
</pre>
|
|
<p class="body">
|
|
To configure the check so that it allows package visible members:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="VisibilityModifier">
|
|
<property name="packageAllowed" value="true;"/>
|
|
</module>
|
|
</pre>
|
|
<p class="body">
|
|
To configure the check so that it allows no public members:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="VisibilityModifier">
|
|
<property name="publicMemberPattern" value="^$"/>
|
|
</module>
|
|
</pre>
|
|
<h4>Package</h4>
|
|
<p class="body">
|
|
com.puppycrawl.tools.checkstyle.checks
|
|
</p>
|
|
<h4>Parent Module</h4>
|
|
<p class="body">
|
|
TreeWalker
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<hr />
|
|
<p>
|
|
Copyright © 2002 Oliver Burn. All rights Reserved.
|
|
</p>
|
|
|
|
</body>
|
|
</html> |