Interface Emitter
public interface Emitter
A dialect of generated code: REST Docs descriptors, WireMock stubs, and the like.
Implementations need a public no-argument constructor, as ServiceLoader
requires, and must not keep state between calls to emit(EmitterContext).
-
Method Summary
Modifier and TypeMethodDescriptionThe libraries the generated code needs, which the plugin adds to the source sets it generates into when the project does not declare them itself.voidemit(EmitterContext context) Writes this emitter's classes for one contract.id()The emitter's identifier: lower case, such asrestdocs.What this emitter writes with the options it is given: the plugin places Java sources in source sets, resources on their classpath, and files in neither, and fails a configuration that does not fit what is declared here -- source sets for an emitter that writes neither Java nor resources, or none for one that writes Java.The classified constructs this emitter represents in full.
-
Method Details
-
id
String id()The emitter's identifier: lower case, such asrestdocs. It names the package its companion classes go in, under the base package.- Returns:
- the identifier
-
dependencies
List<ManagedDependency> dependencies()The libraries the generated code needs, which the plugin adds to the source sets it generates into when the project does not declare them itself.- Returns:
- the dependencies; empty when the generated code needs none
-
represents
The classified constructs this emitter represents in full. For any other construct in a class, the emitter writes the affected method withEmitterContext.degraded(String, String, com.arc_e_tect.gradle.apionly.transcriberj.model.Finding).- Returns:
- the constructs represented
-
produces
What this emitter writes with the options it is given: the plugin places Java sources in source sets, resources on their classpath, and files in neither, and fails a configuration that does not fit what is declared here -- source sets for an emitter that writes neither Java nor resources, or none for one that writes Java.Declare only what the options select: an emitter whose option switches Java off and files on returns
Output.FILESalone for that option. An emitter that does not override this method is taken to write Java and resources, as every emitter did before files existed.- Parameters:
options- the options the project gave this emitter; empty when it gave none- Returns:
- what the emitter writes; never
null
-
emit
Writes this emitter's classes for one contract.- Parameters:
context- the contract, the settings, the class names and where to write
-