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.
  • Field Details

  • Constructor Details

  • Method Details

    • 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 the java.lang package.
      Parameters:
      cub - Instance of ConvertUtilsBean to 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 the java.lang package.
      Parameters:
      cub - Instance of ConvertUtilsBean to 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 finishLocalSetup is called to allow completion of the bean's local setup, after that the method setupChild is called for each child Configuration of configuration.

      Specified by:
      configure in interface Configurable
      Parameters:
      config - the configuration to use.
      Throws:
      CheckstyleException - if there is a configuration error.
      See Also:
    • tryCopyProperty

      private void tryCopyProperty(String key, Object value, boolean recheck) throws CheckstyleException
      Recheck property and try to copy it.
      Parameters:
      key - key of value
      value - value
      recheck - 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:
      contextualize in interface Contextualizable
      Parameters:
      context - the context.
      Throws:
      CheckstyleException - if there is a contextualization error.
      See Also:
    • 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 CheckstyleException if childConf is null 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: