Class SourceAwareCustomizer

java.lang.Object
All Implemented Interfaces:
CompilationUnitAware, CompilationUnit.IPrimaryClassNodeOperation

public class SourceAwareCustomizer
extends DelegatingCustomizer
A base class for customizers which only have to be applied on specific source units. This is for example useful if you want a customizer to be applied only for files matching some extensions.

For convenience, this class implements several methods that you may extend to customize the behaviour of this utility. For example, if you want to apply a customizer only for classes matching the '.foo' file extension, then you only have to override the acceptExtension(String) method:

return "foo".equals(extension)
Since:
2.1.0
  • Constructor Details

  • Method Details

    • call

      public void call​(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException
      Specified by:
      call in interface CompilationUnit.IPrimaryClassNodeOperation
      Overrides:
      call in class DelegatingCustomizer
      Throws:
      CompilationFailedException
    • setBaseNameValidator

      public void setBaseNameValidator​(Closure<java.lang.Boolean> baseNameValidator)
    • setExtensionValidator

      public void setExtensionValidator​(Closure<java.lang.Boolean> extensionValidator)
    • setSourceUnitValidator

      public void setSourceUnitValidator​(Closure<java.lang.Boolean> sourceUnitValidator)
    • setClassValidator

      public void setClassValidator​(Closure<java.lang.Boolean> classValidator)
    • accept

      public boolean accept​(java.lang.String fileName)
    • acceptClass

      public boolean acceptClass​(ClassNode cnode)
    • acceptSource

      public boolean acceptSource​(SourceUnit unit)
    • acceptExtension

      public boolean acceptExtension​(java.lang.String extension)
    • acceptBaseName

      public boolean acceptBaseName​(java.lang.String baseName)