Interface EmitterContext
public interface EmitterContext
What an emitter is given to write one contract's classes.
-
Method Summary
Modifier and TypeMethodDescriptionRecords that a generated method cannot represent a construct, and returns the statement its body consists of instead: one that throwsUnsupportedOperationExceptionwith the reason and, where there is one, the remedy.model()The contract.names()The core classes, whose names an emitter's companions follow.settings()How the project has asked for the classes to be generated.voidWrites one Java source file, replacing any file already written for that class in this run.voidwriteResource(String path, String content) Writes one resource file, replacing any file already written at that path in this run -- a properties file a generated or hand-written class reads throughgetResourceAsStream, for instance.
-
Method Details
-
model
ContractModel model()The contract.- Returns:
- the model
-
settings
Settings settings()How the project has asked for the classes to be generated.- Returns:
- the settings
-
names
ClassNames names()The core classes, whose names an emitter's companions follow.- Returns:
- the class names
-
writeJava
Writes one Java source file, replacing any file already written for that class in this run.- Parameters:
packageName- the packagesimpleName- the class's simple namesource- the whole compilation unit
-
writeResource
Writes one resource file, replacing any file already written at that path in this run -- a properties file a generated or hand-written class reads throughgetResourceAsStream, for instance.pathis/-separated and relative to the resource root, and may nest in directories, such as"META-INF/emitter/service.properties". It may not be absolute, and may not use empty,.or..segments.- Parameters:
path- the resource's path within the resource rootcontent- the resource's content, written UTF-8
-
degraded
Records that a generated method cannot represent a construct, and returns the statement its body consists of instead: one that throwsUnsupportedOperationExceptionwith the reason and, where there is one, the remedy. Every degraded method is reported at the end of generation.- Parameters:
className- the simple name of the class the method is inmethod- the method, as a reader would name it, such asbody(String)finding- the construct it cannot represent- Returns:
- a Java statement, without indentation
-