Class JavaFile.Builder

java.lang.Object
io.micronaut.sourcegen.javapoet.JavaFile.Builder
Enclosing class:
JavaFile

public static final class JavaFile.Builder extends Object
  • Field Details

    • staticImports

      public final Set<String> staticImports
  • Method Details

    • addFileComment

      public JavaFile.Builder addFileComment(String format, Object... args)
    • addStaticImport

      public JavaFile.Builder addStaticImport(Enum<?> constant)
    • addStaticImport

      public JavaFile.Builder addStaticImport(Class<?> clazz, String... names)
    • addStaticImport

      public JavaFile.Builder addStaticImport(ClassName className, String... names)
    • skipJavaLangImports

      public JavaFile.Builder skipJavaLangImports(boolean skipJavaLangImports)
      Call this to omit imports for classes in java.lang, such as java.lang.String.

      By default, JavaPoet explicitly imports types in java.lang to defend against naming conflicts. Suppose an (ill-advised) class is named com.example.String. When java.lang imports are skipped, generated code in com.example that references java.lang.String will get com.example.String instead.

    • indent

      public JavaFile.Builder indent(String indent)
    • build

      public JavaFile build()