Class JavaModifier.CompilationUnitOperations

java.lang.Object
com.vaadin.copilot.javarewriter.JavaModifier.CompilationUnitOperations
Enclosing class:
JavaModifier

public static class JavaModifier.CompilationUnitOperations extends Object
A class for performing operations on a CompilationUnit.
  • Constructor Details

    • CompilationUnitOperations

      public CompilationUnitOperations(com.github.javaparser.ast.CompilationUnit cu, Class<?> cls)
      Creates a new operations object for the given CompilationUnit and class.
      Parameters:
      cu - The CompilationUnit to operate on.
      cls - The class that the CompilationUnit represents.
  • Method Details

    • addClassAnnotation

      public void addClassAnnotation(Class<? extends Annotation> annotation, String value) throws IOException
      Adds a specified annotation with a value to the public type in the class represented by the provided Class object. This is primarily used to dynamically modify the source code of a class by adding annotations that may influence its behavior at runtime or during further processing.
      Parameters:
      annotation - The annotation class to add to the class.
      value - The value to assign to the annotation.
      Throws:
      IOException - If an error occurs during file operations or if the class does not contain an application type where the annotation can be added.
    • addInterface

      public void addInterface(Class<?> interfaceClass)
      Adds an interface to the public type in the class.
      Parameters:
      interfaceClass - The interface class to add to the class.