Package com.squareup.javapoet
Class JavaFile
- java.lang.Object
-
- com.squareup.javapoet.JavaFile
-
public final class JavaFile extends java.lang.Object
A Java file containing a single top level class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavaFile.Builder
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>
alwaysQualify
CodeBlock
fileComment
private java.lang.String
indent
private static java.lang.Appendable
NULL_APPENDABLE
java.lang.String
packageName
boolean
skipJavaLangImports
private java.util.Set<java.lang.String>
staticImports
TypeSpec
typeSpec
-
Constructor Summary
Constructors Modifier Constructor Description private
JavaFile(JavaFile.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JavaFile.Builder
builder(java.lang.String packageName, TypeSpec typeSpec)
private void
emit(CodeWriter codeWriter)
boolean
equals(java.lang.Object o)
private void
fillAlwaysQualifiedNames(TypeSpec spec, java.util.Set<java.lang.String> alwaysQualifiedNames)
int
hashCode()
JavaFile.Builder
toBuilder()
javax.tools.JavaFileObject
toJavaFileObject()
java.lang.String
toString()
void
writeTo(java.io.File directory)
Writes this todirectory
as UTF-8 using the standard directory structure.void
writeTo(java.lang.Appendable out)
void
writeTo(java.nio.file.Path directory)
Writes this todirectory
as UTF-8 using the standard directory structure.void
writeTo(java.nio.file.Path directory, java.nio.charset.Charset charset)
Writes this todirectory
with the providedcharset
using the standard directory structure.void
writeTo(javax.annotation.processing.Filer filer)
Writes this tofiler
.java.io.File
writeToFile(java.io.File directory)
Writes this todirectory
as UTF-8 using the standard directory structure.java.nio.file.Path
writeToPath(java.nio.file.Path directory)
Writes this todirectory
as UTF-8 using the standard directory structure.java.nio.file.Path
writeToPath(java.nio.file.Path directory, java.nio.charset.Charset charset)
Writes this todirectory
with the providedcharset
using the standard directory structure.
-
-
-
Field Detail
-
NULL_APPENDABLE
private static final java.lang.Appendable NULL_APPENDABLE
-
fileComment
public final CodeBlock fileComment
-
packageName
public final java.lang.String packageName
-
typeSpec
public final TypeSpec typeSpec
-
skipJavaLangImports
public final boolean skipJavaLangImports
-
staticImports
private final java.util.Set<java.lang.String> staticImports
-
alwaysQualify
private final java.util.Set<java.lang.String> alwaysQualify
-
indent
private final java.lang.String indent
-
-
Constructor Detail
-
JavaFile
private JavaFile(JavaFile.Builder builder)
-
-
Method Detail
-
fillAlwaysQualifiedNames
private void fillAlwaysQualifiedNames(TypeSpec spec, java.util.Set<java.lang.String> alwaysQualifiedNames)
-
writeTo
public void writeTo(java.lang.Appendable out) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTo
public void writeTo(java.nio.file.Path directory) throws java.io.IOException
Writes this todirectory
as UTF-8 using the standard directory structure.- Throws:
java.io.IOException
-
writeTo
public void writeTo(java.nio.file.Path directory, java.nio.charset.Charset charset) throws java.io.IOException
Writes this todirectory
with the providedcharset
using the standard directory structure.- Throws:
java.io.IOException
-
writeToPath
public java.nio.file.Path writeToPath(java.nio.file.Path directory) throws java.io.IOException
Writes this todirectory
as UTF-8 using the standard directory structure. Returns thePath
instance to which source is actually written.- Throws:
java.io.IOException
-
writeToPath
public java.nio.file.Path writeToPath(java.nio.file.Path directory, java.nio.charset.Charset charset) throws java.io.IOException
Writes this todirectory
with the providedcharset
using the standard directory structure. Returns thePath
instance to which source is actually written.- Throws:
java.io.IOException
-
writeTo
public void writeTo(java.io.File directory) throws java.io.IOException
Writes this todirectory
as UTF-8 using the standard directory structure.- Throws:
java.io.IOException
-
writeToFile
public java.io.File writeToFile(java.io.File directory) throws java.io.IOException
Writes this todirectory
as UTF-8 using the standard directory structure. Returns theFile
instance to which source is actually written.- Throws:
java.io.IOException
-
writeTo
public void writeTo(javax.annotation.processing.Filer filer) throws java.io.IOException
Writes this tofiler
.- Throws:
java.io.IOException
-
emit
private void emit(CodeWriter codeWriter) throws java.io.IOException
- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toJavaFileObject
public javax.tools.JavaFileObject toJavaFileObject()
-
builder
public static JavaFile.Builder builder(java.lang.String packageName, TypeSpec typeSpec)
-
toBuilder
public JavaFile.Builder toBuilder()
-
-