Class AutomaticBean
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- All Implemented Interfaces:
Configurable,Contextualizable
- Direct Known Subclasses:
AbstractViolationReporter,BeforeExecutionExclusionFileFilter,Checker,DefaultLogger,MetadataGeneratorLogger,SarifLogger,SeverityMatchFilter,SuppressionCommentFilter,SuppressionFilter,SuppressionSingleFilter,SuppressionXpathFilter,SuppressionXpathSingleFilter,SuppressWarningsFilter,SuppressWithNearbyCommentFilter,SuppressWithPlainTextCommentFilter,XMLLogger,XpathFileGeneratorAstFilter,XpathFileGeneratorAuditListener
public abstract class AutomaticBean extends java.lang.Object implements Configurable, Contextualizable
A Java Bean that implements the component lifecycle interfaces by calling the bean's setters for all configuration attributes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAutomaticBean.OutputStreamOptionsEnum to specify behaviour regarding ignored modules.private static classAutomaticBean.PatternConverterA converter that converts strings to patterns.private static classAutomaticBean.RelaxedAccessModifierArrayConverterA converter that converts strings toAccessModifierOption.private static classAutomaticBean.RelaxedStringArrayConverterA converter that does not care whether the array elements contain String characters like '*' or '_'.private static classAutomaticBean.ScopeConverterA converter that converts strings to scope.private static classAutomaticBean.SeverityLevelConverterA converter that converts strings to severity level.private static classAutomaticBean.UriConverterA converter that converts strings to uri.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCOMMA_SEPARATORComma separator for StringTokenizer.private ConfigurationconfigurationThe configuration of this bean.
-
Constructor Summary
Constructors Constructor Description AutomaticBean()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration config)Implements the Configurable interface using bean introspection.voidcontextualize(Context context)Implements the Contextualizable interface using bean introspection.private static org.apache.commons.beanutils.BeanUtilsBeancreateBeanUtilsBean()Creates a BeanUtilsBean that is configured to use type converters that throw a ConversionException instead of using the default value when something goes wrong.protected abstract voidfinishLocalSetup()Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.protected ConfigurationgetConfiguration()Returns the configuration that was used to configure this component.private static voidregisterCustomTypes(org.apache.commons.beanutils.ConvertUtilsBean cub)Register custom types of JDK like URI and Checkstyle specific classes to use with BeanUtils.private static voidregisterIntegralTypes(org.apache.commons.beanutils.ConvertUtilsBean cub)Register basic types of JDK like boolean, int, and String to use with BeanUtils.protected voidsetupChild(Configuration childConf)Called by configure() for every child of this component's Configuration.private voidtryCopyProperty(java.lang.String key, java.lang.Object value, boolean recheck)Recheck property and try to copy it.
-
-
-
Field Detail
-
COMMA_SEPARATOR
private static final java.lang.String COMMA_SEPARATOR
Comma separator for StringTokenizer.- See Also:
- Constant Field Values
-
configuration
private Configuration configuration
The configuration of this bean.
-
-
Constructor Detail
-
AutomaticBean
public AutomaticBean()
-
-
Method Detail
-
finishLocalSetup
protected abstract void finishLocalSetup() throws CheckstyleException
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.The default implementation does nothing.
- Throws:
CheckstyleException- if there is a configuration error.
-
createBeanUtilsBean
private static org.apache.commons.beanutils.BeanUtilsBean createBeanUtilsBean()
Creates a BeanUtilsBean that is configured to use type converters that throw a ConversionException instead of using the default value when something goes wrong.- Returns:
- a configured BeanUtilsBean
-
registerIntegralTypes
private static void registerIntegralTypes(org.apache.commons.beanutils.ConvertUtilsBean cub)
Register basic types of JDK like boolean, int, and String to use with BeanUtils. All these types are found in thejava.langpackage.- Parameters:
cub- Instance ofConvertUtilsBeanto register types with.
-
registerCustomTypes
private static void registerCustomTypes(org.apache.commons.beanutils.ConvertUtilsBean cub)
Register custom types of JDK like URI and Checkstyle specific classes to use with BeanUtils. None of these types should be found in thejava.langpackage.- Parameters:
cub- Instance ofConvertUtilsBeanto register types with.
-
configure
public final void configure(Configuration config) throws CheckstyleException
Implements the Configurable interface using bean introspection.Subclasses are allowed to add behaviour. After the bean based setup has completed first the method
finishLocalSetupis called to allow completion of the bean's local setup, after that the methodsetupChildis called for eachchild Configurationofconfiguration.- Specified by:
configurein interfaceConfigurable- Parameters:
config- the configuration to use.- Throws:
CheckstyleException- if there is a configuration error.- See Also:
Configurable
-
tryCopyProperty
private void tryCopyProperty(java.lang.String key, java.lang.Object value, boolean recheck) throws CheckstyleException
Recheck property and try to copy it.- Parameters:
key- key of valuevalue- valuerecheck- whether to check for property existence before copy- Throws:
CheckstyleException- when property defined incorrectly
-
contextualize
public final void contextualize(Context context) throws CheckstyleException
Implements the Contextualizable interface using bean introspection.- Specified by:
contextualizein interfaceContextualizable- Parameters:
context- the context.- Throws:
CheckstyleException- if there is a contextualization error.- See Also:
Contextualizable
-
getConfiguration
protected final Configuration getConfiguration()
Returns the configuration that was used to configure this component.- Returns:
- the configuration that was used to configure this component.
-
setupChild
protected void setupChild(Configuration childConf) throws CheckstyleException
Called by configure() for every child of this component's Configuration.The default implementation throws
CheckstyleExceptionifchildConfisnullbecause it doesn't support children. It must be overridden to validate and support children that are wanted.- Parameters:
childConf- a child of this component's Configuration- Throws:
CheckstyleException- if there is a configuration error.- See Also:
Configuration.getChildren()
-
-