Class WriteContext

java.lang.Object
nl.datasteel.crudcraft.codegen.writer.WriteContext

public class WriteContext extends Object
Shared context for writer components. Holds the processing environment and provides a helper to write files with consistent error handling.
  • Constructor Details

    • WriteContext

      public WriteContext(ProcessingEnvironment env)
      Constructs a WriteContext with the given processing environment.
      Parameters:
      env - the ProcessingEnvironment instance
    • WriteContext

      public WriteContext(WriteContext other)
      Creates a deep/shallow copy of the context.
  • Method Details

    • snapshotOf

      public static WriteContext snapshotOf(WriteContext other)
      Creates a snapshot of the current context. Useful for passing around a consistent state without modifying the original.
    • env

      public ProcessingEnvironment env()
      Returns the processing environment for this context. This is used to access the file system, messager, and other utilities.
      Returns:
      the ProcessingEnvironment instance
    • findTypeElement

      public TypeElement findTypeElement(String fqcn)
      Finds a TypeElement by its fully qualified class name.
      Parameters:
      fqcn - fully qualified class name
      Returns:
      the TypeElement or null if not found
    • write

      public void write(com.squareup.javapoet.JavaFile jf)
      Writes a JavaFile to the file system, handling any IO exceptions. If an error occurs, it logs an error message using the processing environment's messager.
      Parameters:
      jf - the JavaFile to write