com.puppycrawl.tools.checkstyle.checks
Class AbstractOptionCheck<T extends Enum<T>>

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.Check
              extended by com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck<T>
Type Parameters:
T - the type of the option.
All Implemented Interfaces:
Configurable, Contextualizable
Direct Known Subclasses:
EmptyBlockCheck, EmptyForInitializerPadCheck, EmptyForIteratorPadCheck, ImportOrderCheck, LeftCurlyCheck, MethodParamPadCheck, OperatorWrapCheck, ParenPadCheck, RightCurlyCheck, TypecastParenPadCheck

public abstract class AbstractOptionCheck<T extends Enum<T>>
extends Check

Abstract class for checks with a parameter named option, where the option is identified by a Enum. The logic to convert from a string representation to the Enum is to String.trim() the string and convert using String.toUpperCase() and then look up using Enum.valueOf(java.lang.Class, java.lang.String).

Author:
Oliver Burn, Rick Giles

Constructor Summary
AbstractOptionCheck(T aDefault, Class<T> aOptionClass)
          Creates a new AbstractOptionCheck instance.
 
Method Summary
 T getAbstractOption()
           
 void setOption(String aOption)
          Set the option to enforce.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens, visitToken
 
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

AbstractOptionCheck

public AbstractOptionCheck(T aDefault,
                           Class<T> aOptionClass)
Creates a new AbstractOptionCheck instance.

Parameters:
aDefault - the default option.
aOptionClass - the class for the option. Required due to a quirk in the Java language.
Method Detail

setOption

public void setOption(String aOption)
               throws ConversionException
Set the option to enforce.

Parameters:
aOption - string to decode option from
Throws:
ConversionException - if unable to decode

getAbstractOption

public T getAbstractOption()
Returns:
the AbstractOption set

Back to the Checkstyle Home Page