Package com.puppycrawl.tools.checkstyle
Class AbstractAutomaticBean
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
- All Implemented Interfaces:
Configurable
,Contextualizable
- Direct Known Subclasses:
AbstractViolationReporter
,AutomaticBean
,BeforeExecutionExclusionFileFilter
,Checker
,DefaultLogger
,MetadataGeneratorLogger
,SarifLogger
,SeverityMatchFilter
,SuppressionCommentFilter
,SuppressionFilter
,SuppressionSingleFilter
,SuppressionXpathFilter
,SuppressionXpathSingleFilter
,SuppressWarningsFilter
,SuppressWithNearbyCommentFilter
,SuppressWithNearbyTextFilter
,SuppressWithPlainTextCommentFilter
,XMLLogger
,XpathFileGeneratorAstFilter
,XpathFileGeneratorAuditListener
public abstract class AbstractAutomaticBean
extends 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 ClassesModifier and TypeClassDescriptionstatic enum
Enum to specify behaviour regarding ignored modules.private static final class
A converter that converts a comma-separated string into an array of patterns.private static final class
A converter that converts a string to a pattern.private static final class
A converter that converts strings toAccessModifierOption
.private static final class
A converter that does not care whether the array elements contain String characters like '*' or '_'.private static final class
A converter that converts strings to scope.private static final class
A converter that converts strings to severity level.private static final class
A converter that converts strings to uri. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Comma separator for StringTokenizer.private Configuration
The configuration of this bean. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
configure
(Configuration config) Implements the Configurable interface using bean introspection.final void
contextualize
(Context context) Implements the Contextualizable interface using bean introspection.private static org.apache.commons.beanutils.BeanUtilsBean
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 void
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.protected final Configuration
Returns the configuration that was used to configure this component.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.private static void
registerIntegralTypes
(org.apache.commons.beanutils.ConvertUtilsBean cub) Register basic types of JDK like boolean, int, and String to use with BeanUtils.protected void
setupChild
(Configuration childConf) Called by configure() for every child of this component's Configuration.private void
tryCopyProperty
(String key, Object value, boolean recheck) Recheck property and try to copy it.
-
Field Details
-
COMMA_SEPARATOR
Comma separator for StringTokenizer.- See Also:
-
configuration
The configuration of this bean.
-
-
Constructor Details
-
AbstractAutomaticBean
public AbstractAutomaticBean()
-
-
Method Details
-
finishLocalSetup
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
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
Register basic types of JDK like boolean, int, and String to use with BeanUtils. All these types are found in thejava.lang
package.- Parameters:
cub
- Instance ofConvertUtilsBean
to register types with.
-
registerCustomTypes
Register custom types of JDK like URI and Checkstyle specific classes to use with BeanUtils. None of these types should be found in thejava.lang
package.- Parameters:
cub
- Instance ofConvertUtilsBean
to register types with.
-
configure
Implements the Configurable interface using bean introspection.Subclasses are allowed to add behaviour. After the bean based setup has completed first the method
finishLocalSetup
is called to allow completion of the bean's local setup, after that the methodsetupChild
is called for eachchild Configuration
ofconfiguration
.- Specified by:
configure
in interfaceConfigurable
- Parameters:
config
- the configuration to use.- Throws:
CheckstyleException
- if there is a configuration error.- See Also:
-
tryCopyProperty
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
Implements the Contextualizable interface using bean introspection.- Specified by:
contextualize
in interfaceContextualizable
- Parameters:
context
- the context.- Throws:
CheckstyleException
- if there is a contextualization error.- See Also:
-
getConfiguration
Returns the configuration that was used to configure this component.- Returns:
- the configuration that was used to configure this component.
-
setupChild
Called by configure() for every child of this component's Configuration.The default implementation throws
CheckstyleException
ifchildConf
isnull
because 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:
-