## com.puppycrawl.tools.checkstyle.checks.annotation
Class MissingOverrideCheck

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
              com.puppycrawl.tools.checkstyle.api.Check
                  com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck

All Implemented Interfaces:
  Configurable, Contextualizable

    public final class MissingOverrideCheck

extends Check

This class is used to verify that the `Override` annotation is present when the inheritDoc javadoc tag is present.

Rationale: The `Override` annotation helps compiler tools ensure that an override is actually occurring. It is quite easy to accidentally overload a method or hide a static method and using the `Override` annotation points out these problems.

This check will log a violation if using the inheritDoc tag on a method that is not valid (ex: private, or static method).

There is a slight difference between the Override annotation in Java 5 versus Java 6 and above. In Java 5, any method overridden from an interface cannot be annotated with Override. In Java 6 this behavior is allowed.

As a result of the aforementioned difference between Java 5 and Java 6, a property called `javaFiveCompatibility` is available. This property will only check classes, interfaces, etc. that do not contain the extends or implements keyword or are not anonymous classes. This means it only checks methods overridden from `java.lang.Object` Java 5 Compatibility mode severely limits this check. It is recommended to only use it on Java 5 source

     <module name="MissingOverride">
        <property name="javaFiveCompatibility"
            value="true"/>
     </module>

Author:
  Travis Schneeberger

Constructor Summary
`MissingOverrideCheck()`

Method Summary
`int[]` `getAcceptableTokens()` The configurable token set.
`int[]` `getDefaultTokens()` Returns the default token a check is interested in.
`int[]` `getRequiredTokens()` The tokens that this check must be registered for.
`void` `setJavaFiveCompatibility(boolean aCompatibility)` Sets Java 5 compatibility mode.
`void` `visitToken(DetailAST aAST)` Called to process a token.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
`beginTree, destroy, finishTree, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens`

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
`getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity`

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
`configure, contextualize, finishLocalSetup, getConfiguration, setupChild`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MissingOverrideCheck

    public MissingOverrideCheck()

Method Detail

### setJavaFiveCompatibility

    public void setJavaFiveCompatibility(boolean aCompatibility)

  Sets Java 5 compatibility mode.

  In Java 5, this check could flag code that is not valid for the Override annotation even though it is a proper override. See the class documentation for more information.

  Set this to true to turn on Java 5 compatibility mode. Set this to false to turn off Java 5 compatibility mode.

  Parameters:
    `aCompatibility` - compatibility or not

### getDefaultTokens

    public int[] getDefaultTokens()

  Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.

  Specified by:
    `getDefaultTokens` in class `Check`
  Returns:
    the default tokens
  See Also:
    `TokenTypes`

### getAcceptableTokens

    public int[] getAcceptableTokens()

  The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.

  Overrides:
    `getAcceptableTokens` in class `Check`
  Returns:
    the token set this check is designed for.
  See Also:
    `TokenTypes`

### getRequiredTokens

    public int[] getRequiredTokens()

  The tokens that this check must be registered for.

  Overrides:
    `getRequiredTokens` in class `Check`
  Returns:
    the token set this must be registered for.
  See Also:
    `TokenTypes`

### visitToken

    public void visitToken(DetailAST aAST)

  Called to process a token.

  Overrides:
    `visitToken` in class `Check`
  Parameters:
    `aAST` - the token to process

Copyright © 2001-2011. All Rights Reserved.