Class CodeWriter

java.lang.Object
com.squareup.javapoet.CodeWriter

final class CodeWriter extends Object
Converts a JavaFile to a string suitable to both human- and javac-consumption. This honors imports, indentation, and deferred variable names.
  • Field Details

    • NO_PACKAGE

      private static final String NO_PACKAGE
      Sentinel value that indicates that no user-provided package has been set.
    • indent

      private final String indent
    • out

      private final LineWrapper out
    • indentLevel

      private int indentLevel
    • javadoc

      private boolean javadoc
    • comment

      private boolean comment
    • packageName

      private String packageName
    • typeSpecStack

      private final List<TypeSpec> typeSpecStack
    • staticImportClassNames

      private final Set<String> staticImportClassNames
    • staticImports

      private final Set<String> staticImports
    • alwaysQualify

      private final Set<String> alwaysQualify
    • importedTypes

      private final Map<String,ClassName> importedTypes
    • importableTypes

      private final Map<String,ClassName> importableTypes
    • referencedNames

      private final Set<String> referencedNames
    • currentTypeVariables

      private final CodeWriter.Multiset<String> currentTypeVariables
    • trailingNewline

      private boolean trailingNewline
    • statementLine

      int statementLine
      When emitting a statement, this is the line of the statement currently being written. The first line of a statement is indented normally and subsequent wrapped lines are double-indented. This is -1 when the currently-written line isn't part of a statement.
  • Constructor Details

  • Method Details