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)
| Fields inherited from class | Fields |
|---|---|
class DelegatingCustomizer |
delegate |
| Constructor and description |
|---|
SourceAwareCustomizer(CompilationCustomizer delegate)Creates a source-aware wrapper around another compilation customizer. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
accept(String fileName)Checks whether a source file name is accepted by the base-name and extension validators. |
|
public boolean |
acceptBaseName(String baseName)Checks whether a base file name is accepted. |
|
public boolean |
acceptClass(ClassNode cnode)Checks whether a class node is accepted. |
|
public boolean |
acceptExtension(String extension)Checks whether a file extension is accepted. |
|
public boolean |
acceptSource(SourceUnit unit)Checks whether a source unit is accepted. |
|
public void |
call(SourceUnit source, GeneratorContext context, ClassNode classNode)Invokes the delegate only when the source and class validators accept the current input. |
|
public void |
setBaseNameValidator(Closure<Boolean> baseNameValidator)Sets the predicate used to validate source base names. |
|
public void |
setClassValidator(Closure<Boolean> classValidator)Sets the predicate used to validate class nodes. |
|
public void |
setExtensionValidator(Closure<Boolean> extensionValidator)Sets the predicate used to validate source file extensions. |
|
public void |
setSourceUnitValidator(Closure<Boolean> sourceUnitValidator)Sets the predicate used to validate whole source units. |
| Methods inherited from class | Name |
|---|---|
class DelegatingCustomizer |
call, setCompilationUnit |
class CompilationCustomizer |
getPhase |
Creates a source-aware wrapper around another compilation customizer.
delegate - the customizer to invoke when the source matchesChecks whether a source file name is accepted by the base-name and extension validators.
fileName - the file name to inspecttrue if the file name is acceptedChecks whether a base file name is accepted.
baseName - the base file name to inspecttrue if the base name is acceptedChecks whether a class node is accepted.
cnode - the class node to inspecttrue if the class is acceptedChecks whether a file extension is accepted.
extension - the extension to inspecttrue if the extension is acceptedChecks whether a source unit is accepted.
unit - the source unit to inspecttrue if the source is acceptedInvokes the delegate only when the source and class validators accept the current input.
source - the source unit being customizedcontext - the current generator contextclassNode - the class node being customizedSets the predicate used to validate source base names.
baseNameValidator - the validator to useSets the predicate used to validate class nodes.
classValidator - the validator to useSets the predicate used to validate source file extensions.
extensionValidator - the validator to useCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.