Class TraitCodegenWriter
java.lang.Object
software.amazon.smithy.utils.AbstractCodeWriter<W>
software.amazon.smithy.codegen.core.SymbolWriter<TraitCodegenWriter,software.amazon.smithy.traitcodegen.writer.TraitCodegenImportContainer>
 
software.amazon.smithy.traitcodegen.writer.TraitCodegenWriter
- All Implemented Interfaces:
 SymbolDependencyContainer
public class TraitCodegenWriter
extends SymbolWriter<TraitCodegenWriter,software.amazon.smithy.traitcodegen.writer.TraitCodegenImportContainer> 
Writes Java code for trait definitions.
 
This writer supports two custom formatters, a Java type formatter '$T' and a Base type formatter '$B'.
TraitCodegenWriter.JavaTypeFormatter|'T'- This formatter handles the formatting of
     Java types and also ensures that parameterized types (such as 
List<String>are written correctly. TraitCodegenWriter.BaseTypeFormatter|'B'- This formatter allows you to use the base type
     for a trait. For example a String Trait may have a base type of 
ShapeId. To write this base type, use the$Bformatter and provide the trait symbol. Note that if no base type is found (i.e. type is not a trait) then this formatter behaves exactly the same as theTraitCodegenWriter.JavaTypeFormatter. TraitCodegenWriter.CapitalizingFormatter|'U'- This formatter will capitalize the first letter of any string literal it is used to format.
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA factory class to createTraitCodegenWriters. - 
Constructor Summary
ConstructorsConstructorDescriptionTraitCodegenWriter(String fileName, String namespace, TraitCodegenSettings settings)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidnewLine()voidoverride()toString()Gets the contents of the generated code.voidwriteDocString(String contents) Writes the provided text in the format of a Java doc string.Methods inherited from class software.amazon.smithy.codegen.core.SymbolWriter
addDependency, addImport, addUseImports, addUseImports, getDependencies, getImportContainer, setRelativizeSymbolsMethods inherited from class software.amazon.smithy.utils.AbstractCodeWriter
call, closeBlock, consumer, copySettingsFrom, dedent, dedent, disableNewlines, enableNewlines, enableStackTraceComments, ensureNewline, format, formatLiteral, formatWithStackTraceElement, getContext, getContext, getDebugInfo, getDebugInfo, getExpressionStart, getIndentLevel, getIndentText, getInsertTrailingNewline, getNewline, getNewlinePrefix, getTrimBlankLines, getTrimTrailingSpaces, indent, indent, injectSection, insertTrailingNewline, insertTrailingNewline, isStackTraceRelevant, onSection, onSection, openBlock, openBlock, openBlock, openBlock, openBlock, openBlock, openBlock, openBlock, popState, pushFilteredState, pushState, pushState, pushState, putContext, putContext, putFormatter, removeContext, setExpressionStart, setIndentText, setNewline, setNewline, setNewlinePrefix, trimBlankLines, trimBlankLines, trimTrailingSpaces, trimTrailingSpaces, unwrite, write, writeInline, writeInlineWithNoFormatting, writeOptional, writeWithNoFormatting 
- 
Constructor Details
- 
TraitCodegenWriter
 
 - 
 - 
Method Details
- 
writeDocString
Writes the provided text in the format of a Java doc string.- Parameters:
 contents- text to format as a doc string.
 - 
toString
Description copied from class:AbstractCodeWriterGets the contents of the generated code.The result will have an appended newline if the AbstractCodeWriter is configured to always append a newline. A newline is only appended in these cases if the result does not already end with a newline.
- Overrides:
 toStringin classAbstractCodeWriter<TraitCodegenWriter>- Returns:
 - Returns the generated code.
 
 - 
getPackageHeader
 - 
getHeader
 - 
newLine
public void newLine() - 
override
public void override() 
 -