Interface UseShapeWriterObserver<T extends CodegenWriter<T,?>>
-
- Type Parameters:
T
- Type of CodegenWriter being used.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface UseShapeWriterObserver<T extends CodegenWriter<T,?>>
An observer invoked when a shape CodegenWriter is used.The following example defines a
UseShapeWriterObserver
that writes a comment before a shape is written:public final class MyObserver implements UseShapeWriterObserver<MyWriter> { \@Override public void observe(Shape shape, Symbol symbol, SymbolProvider symbolProvider, MyWriter writer) { writer.write("/// Writing $L", shape.getId()); } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
observe(Shape shape, Symbol symbol, SymbolProvider symbolProvider, T writer)
Invoked when aCodegenWriter
writer is used viaCodegenWriterDelegator.useShapeWriter(Shape, Consumer)
.
-
-
-
Method Detail
-
observe
void observe(Shape shape, Symbol symbol, SymbolProvider symbolProvider, T writer)
Invoked when aCodegenWriter
writer is used viaCodegenWriterDelegator.useShapeWriter(Shape, Consumer)
.This is an extension point that allows code generators to perform any kind of preprocessing they need before code is written to a
CodegenWriter
for a given shape. For example, this could be used to add comments to the generated code to indicate that a file is auto-generated.This method is invoked before the
writerConsumer
ofCodegenWriterDelegator.useShapeWriter(software.amazon.smithy.model.shapes.Shape, java.util.function.Consumer<T>)
is called. This method is invoked within a pushed CodegenWriter state, so any state modifications made to the CodegenWriter will not persist after the thewriterConsumer
has completed (e.g., calls to methods likeCodeWriter.indent()
are not persisted).- Parameters:
shape
- Shape being used.symbol
- Symbol of the shape.symbolProvider
- SymbolProvider associated with the delegator.writer
- Writer being used for the shape.
-
-