Package com.github.javaparser.generator
Class Generator
- java.lang.Object
-
- com.github.javaparser.generator.Generator
-
- Direct Known Subclasses:
NodeGenerator
,TokenKindGenerator
,VisitorGenerator
public abstract class Generator extends Object
A general pattern that the generators in this module will follow.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.github.javaparser.utils.SourceRoot
sourceRoot
-
Constructor Summary
Constructors Modifier Constructor Description protected
Generator(com.github.javaparser.utils.SourceRoot sourceRoot)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addOrReplaceWhenSameSignature(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration containingClassOrInterface, com.github.javaparser.ast.body.CallableDeclaration<?> callable)
Utility method that looks for a method or constructor with an identical signature as "callable" and replaces it with callable.protected <T extends com.github.javaparser.ast.Node & com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
voidannotateGenerated(T node)
protected void
annotateOverridden(com.github.javaparser.ast.body.MethodDeclaration method)
protected <T extends com.github.javaparser.ast.Node & com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
voidannotateSuppressWarnings(T node)
abstract void
generate()
protected void
removeMethodWithSameSignature(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration containingClassOrInterface, com.github.javaparser.ast.body.CallableDeclaration<?> callable)
Removes all methods from containingClassOrInterface that have the same signature as callable.protected void
replaceWhenSameSignature(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration containingClassOrInterface, com.github.javaparser.ast.body.CallableDeclaration<?> callable)
Utility method that looks for a method or constructor with an identical signature as "callable" and replaces it with callable.
-
-
-
Method Detail
-
annotateGenerated
protected <T extends com.github.javaparser.ast.Node & com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> void annotateGenerated(T node)
-
annotateSuppressWarnings
protected <T extends com.github.javaparser.ast.Node & com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> void annotateSuppressWarnings(T node)
-
annotateOverridden
protected void annotateOverridden(com.github.javaparser.ast.body.MethodDeclaration method)
-
addOrReplaceWhenSameSignature
protected void addOrReplaceWhenSameSignature(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration containingClassOrInterface, com.github.javaparser.ast.body.CallableDeclaration<?> callable)
Utility method that looks for a method or constructor with an identical signature as "callable" and replaces it with callable. If not found, adds callable. When the new callable has no javadoc, any old javadoc will be kept.
-
replaceWhenSameSignature
protected void replaceWhenSameSignature(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration containingClassOrInterface, com.github.javaparser.ast.body.CallableDeclaration<?> callable)
Utility method that looks for a method or constructor with an identical signature as "callable" and replaces it with callable. If not found, fails. When the new callable has no javadoc, any old javadoc will be kept. The method or constructor is annotated with the generator class.
-
removeMethodWithSameSignature
protected void removeMethodWithSameSignature(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration containingClassOrInterface, com.github.javaparser.ast.body.CallableDeclaration<?> callable)
Removes all methods from containingClassOrInterface that have the same signature as callable. This is not used by any code, but it is useful when changing a generator and you need to get rid of a set of outdated methods.
-
-