Class Generator

java.lang.Object
com.github.javaparser.generator.Generator
Direct Known Subclasses:
BndGenerator, NodeGenerator, TokenKindGenerator, VisitorGenerator

public abstract class Generator extends Object
A general pattern that the generators in this module will follow.
  • Field Details

    • sourceRoot

      protected final SourceRoot sourceRoot
  • Constructor Details

    • Generator

      protected Generator(SourceRoot sourceRoot)
  • Method Details

    • generate

      public abstract void generate() throws Exception
      Throws:
      Exception
    • annotateGenerated

      protected <T extends Node & NodeWithAnnotations<?>> void annotateGenerated(T node)
    • annotateSuppressWarnings

      protected <T extends Node & NodeWithAnnotations<?>> void annotateSuppressWarnings(T node)
    • annotateOverridden

      protected void annotateOverridden(MethodDeclaration method)
    • addOrReplaceWhenSameSignature

      protected void addOrReplaceWhenSameSignature(ClassOrInterfaceDeclaration containingClassOrInterface, 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(ClassOrInterfaceDeclaration containingClassOrInterface, 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(ClassOrInterfaceDeclaration containingClassOrInterface, 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.