Class WriteContext
java.lang.Object
nl.datasteel.crudcraft.codegen.writer.WriteContext
Shared context for writer components. Holds the processing environment and
provides a helper to write files with consistent error handling.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a WriteContext with the given processing environment.WriteContext(WriteContext other) Creates a deep/shallow copy of the context. -
Method Summary
Modifier and TypeMethodDescriptionenv()Returns the processing environment for this context.findTypeElement(String fqcn) Finds aTypeElementby its fully qualified class name.static WriteContextsnapshotOf(WriteContext other) Creates a snapshot of the current context.voidwrite(com.squareup.javapoet.JavaFile jf) Writes a JavaFile to the file system, handling any IO exceptions.
-
Constructor Details
-
WriteContext
Constructs a WriteContext with the given processing environment.- Parameters:
env- the ProcessingEnvironment instance
-
WriteContext
Creates a deep/shallow copy of the context.
-
-
Method Details
-
snapshotOf
Creates a snapshot of the current context. Useful for passing around a consistent state without modifying the original. -
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
Finds aTypeElementby its fully qualified class name.- Parameters:
fqcn- fully qualified class name- Returns:
- the
TypeElementornullif 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
-