Package com.hendraanggrian.javapoet

Types

AnnotationSpecBuilder
Link copied to clipboard
class AnnotationSpecBuilder
Wrapper of AnnotationSpec.Builder, providing DSL support as a replacement to Java builder.
CodeBlockBuilder
Link copied to clipboard
class CodeBlockBuilder : CodeBlockHandler
Wrapper of CodeBlock.Builder, providing DSL support as a replacement to Java builder.
FieldSpecBuilder
Link copied to clipboard
class FieldSpecBuilder
Wrapper of FieldSpec.Builder, providing DSL support as a replacement to Java builder.
JavaFileBuilder
Link copied to clipboard
class JavaFileBuilder : TypeSpecHandler
Wrapper of JavaFile.Builder, providing DSL support as a replacement to Java builder.
MethodSpecBuilder
Link copied to clipboard
class MethodSpecBuilder : CodeBlockHandler
Wrapper of MethodSpec.Builder, providing DSL support as a replacement to Java builder.
ParameterSpecBuilder
Link copied to clipboard
class ParameterSpecBuilder
Wrapper of ParameterSpec.Builder, providing DSL support as a replacement to Java builder.
SpecDslMarker
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class SpecDslMarker
Delimits spec builders' DSL.
TypeSpecBuilder
Link copied to clipboard
class TypeSpecBuilder
Wrapper of TypeSpec.Builder, providing DSL support as a replacement to Java builder.

Functions

annotationSpecOf
Link copied to clipboard
inline fun <T> annotationSpecOf(): AnnotationSpec
Builds new AnnotationSpec from T.
fun annotationSpecOf(type: ClassName): AnnotationSpec
Builds new AnnotationSpec from ClassName.
fun annotationSpecOf(type: Class<*>): AnnotationSpec
Builds new AnnotationSpec from Class.
fun annotationSpecOf(type: KClass<*>): AnnotationSpec
Builds new AnnotationSpec from KClass.
annotationTypeSpecOf
Link copied to clipboard
fun annotationTypeSpecOf(type: ClassName): TypeSpec
Builds new annotation TypeSpec from ClassName.
fun annotationTypeSpecOf(type: String): TypeSpec
Builds new annotation TypeSpec from name.
anonymousTypeSpecOf
Link copied to clipboard
fun anonymousTypeSpecOf(code: CodeBlock): TypeSpec
Builds new anonymous TypeSpec from CodeBlock.
fun anonymousTypeSpecOf(format: String, vararg args: Any): TypeSpec
Builds new anonymous TypeSpec from formatting.
arrayOf
Link copied to clipboard
inline fun TypeName.arrayOf(): ArrayTypeName
Returns an ArrayTypeName equivalent to TypeName.
inline fun Type.arrayOf(): ArrayTypeName
Returns an ArrayTypeName equivalent to Class.
inline fun KClass<*>.arrayOf(): ArrayTypeName
Returns an ArrayTypeName equivalent to KClass.
fun String.arrayOf(simpleName: String, vararg simpleNames: String): ArrayTypeName
Returns a ClassName created from the given parts and convert it to ArrayTypeName.
asAnnotationSpec
Link copied to clipboard
fun AnnotationMirror.asAnnotationSpec(): AnnotationSpec
Converts AnnotationMirror to AnnotationSpec.
fun Annotation.asAnnotationSpec(includeDefaultValues: Boolean = false): AnnotationSpec
Converts Annotation to AnnotationSpec.
asArrayTypeName
Link copied to clipboard
inline fun GenericArrayType.asArrayTypeName(): ArrayTypeName
Returns an ArrayTypeName equivalent to GenericArrayType.
inline fun ArrayType.asArrayTypeName(): ArrayTypeName
Returns an ArrayTypeName equivalent to ArrayType.
asClassName
Link copied to clipboard
inline fun Class<*>.asClassName(): ClassName
Returns a ClassName equivalent to Class.
inline fun TypeElement.asClassName(): ClassName
Returns a ClassName equivalent to TypeElement.
inline fun KClass<*>.asClassName(): ClassName
Returns a ClassName equivalent to KClass.
asParameterizedTypeName
Link copied to clipboard
inline fun ParameterizedType.asParameterizedTypeName(): ParameterizedTypeName
Returns a ParameterizedTypeName equivalent to ParameterizedType.
asParameterSpec
Link copied to clipboard
fun VariableElement.asParameterSpec(): ParameterSpec
Converts element to ParameterSpec.
asTypeName
Link copied to clipboard
inline fun Type.asTypeName(): TypeName
Returns a TypeName equivalent to Type.
inline fun TypeMirror.asTypeName(): TypeName
Returns a TypeName equivalent to TypeMirror.
inline fun KClass<*>.asTypeName(): TypeName
Returns a TypeName equivalent to KClass.
asTypeVariableName
Link copied to clipboard
inline fun TypeVariable<*>.asTypeVariableName(): TypeVariableName
Returns a TypeVariableName equivalent to java.lang.reflect.TypeVariable.
inline fun TypeParameterElement.asTypeVariableName(): TypeVariableName
Returns a TypeVariableName equivalent to TypeParameterElement.
inline fun TypeVariable.asTypeVariableName(): TypeVariableName
Returns a TypeVariableName equivalent to TypeVariable.
asWildcardTypeName
Link copied to clipboard
inline fun WildcardType.asWildcardTypeName(): TypeName
Returns a WildcardTypeName equivalent to java.lang.reflect.WildcardType.
inline fun WildcardType.asWildcardTypeName(): TypeName
Returns a WildcardTypeName equivalent to WildcardType.
buildAnnotationSpec
Link copied to clipboard
inline fun <T> buildAnnotationSpec(noinline configuration: AnnotationSpecBuilder.() -> Unit): AnnotationSpec
Builds new AnnotationSpec from T, by populating newly created AnnotationSpecBuilder using provided configuration.
fun buildAnnotationSpec(type: ClassName, configuration: AnnotationSpecBuilder.() -> Unit): AnnotationSpec
Builds new AnnotationSpec from ClassName, by populating newly created AnnotationSpecBuilder using provided configuration.
fun buildAnnotationSpec(type: Class<*>, configuration: AnnotationSpecBuilder.() -> Unit): AnnotationSpec
Builds new AnnotationSpec from Class, by populating newly created AnnotationSpecBuilder using provided configuration.
fun buildAnnotationSpec(type: KClass<*>, configuration: AnnotationSpecBuilder.() -> Unit): AnnotationSpec
Builds new AnnotationSpec from KClass, by populating newly created AnnotationSpecBuilder using provided configuration.
buildAnnotationTypeSpec
Link copied to clipboard
fun buildAnnotationTypeSpec(type: ClassName, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new annotation TypeSpec from ClassName, by populating newly created TypeSpecBuilder using provided configuration.
fun buildAnnotationTypeSpec(type: String, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new annotation TypeSpec from name, by populating newly created TypeSpecBuilder using provided configuration.
buildAnonymousTypeSpec
Link copied to clipboard
fun buildAnonymousTypeSpec(code: CodeBlock, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new anonymous TypeSpec from CodeBlock, by populating newly created TypeSpecBuilder using provided configuration.
fun buildAnonymousTypeSpec(format: String, vararg args: Any, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new anonymous TypeSpec from formatting, by populating newly created TypeSpecBuilder using provided configuration.
buildClassTypeSpec
Link copied to clipboard
fun buildClassTypeSpec(type: ClassName, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new class TypeSpec from ClassName, by populating newly created TypeSpecBuilder using provided configuration.
fun buildClassTypeSpec(type: String, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new class TypeSpec from name, by populating newly created TypeSpecBuilder using provided configuration.
buildCodeBlock
Link copied to clipboard
fun buildCodeBlock(configuration: CodeBlockBuilder.() -> Unit): CodeBlock
Builds new CodeBlock, by populating newly created CodeBlockBuilder using provided configuration.
buildConstructorMethodSpec
Link copied to clipboard
fun buildConstructorMethodSpec(configuration: MethodSpecBuilder.() -> Unit): MethodSpec
Builds new constructor MethodSpec, by populating newly created MethodSpecBuilder using provided configuration.
buildEnumTypeSpec
Link copied to clipboard
fun buildEnumTypeSpec(type: ClassName, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new enum TypeSpec from ClassName, by populating newly created TypeSpecBuilder using provided configuration.
fun buildEnumTypeSpec(type: String, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new enum TypeSpec from name, by populating newly created TypeSpecBuilder using provided configuration.
buildFieldSpec
Link copied to clipboard
inline fun <T> buildFieldSpec(name: String, vararg modifiers: Modifier, noinline configuration: FieldSpecBuilder.() -> Unit): FieldSpec
Builds new FieldSpec from T supplying its name and modifiers, by populating newly created FieldSpecBuilder using provided configuration.
fun buildFieldSpec(type: TypeName, name: String, vararg modifiers: Modifier, configuration: FieldSpecBuilder.() -> Unit): FieldSpec
Builds new FieldSpec from TypeName supplying its name and modifiers, by populating newly created FieldSpecBuilder using provided configuration.
fun buildFieldSpec(type: Type, name: String, vararg modifiers: Modifier, configuration: FieldSpecBuilder.() -> Unit): FieldSpec
Builds new FieldSpec from Type supplying its name and modifiers, by populating newly created FieldSpecBuilder using provided configuration.
fun buildFieldSpec(type: KClass<*>, name: String, vararg modifiers: Modifier, configuration: FieldSpecBuilder.() -> Unit): FieldSpec
Builds new FieldSpec from KClass supplying its name and modifiers, by populating newly created FieldSpecBuilder using provided configuration.
buildInterfaceTypeSpec
Link copied to clipboard
fun buildInterfaceTypeSpec(type: ClassName, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new interface TypeSpec from ClassName, by populating newly created TypeSpecBuilder using provided configuration.
fun buildInterfaceTypeSpec(type: String, configuration: TypeSpecBuilder.() -> Unit): TypeSpec
Builds new interface TypeSpec from name, by populating newly created TypeSpecBuilder using provided configuration.
buildJavaFile
Link copied to clipboard
fun buildJavaFile(packageName: String, configuration: JavaFileBuilder.() -> Unit): JavaFile
Builds new JavaFile, by populating newly created JavaFileBuilder using provided configuration.
buildMethodSpec
Link copied to clipboard
fun buildMethodSpec(name: String, configuration: MethodSpecBuilder.() -> Unit): MethodSpec
Builds new MethodSpec with name, by populating newly created MethodSpecBuilder using provided configuration.
buildParameterSpec
Link copied to clipboard
inline fun <T> buildParameterSpec(name: String, vararg modifiers: Modifier, noinline configuration: ParameterSpecBuilder.() -> Unit): ParameterSpec
Builds new ParameterSpec from T, by populating newly created ParameterSpecBuilder using provided configuration.
fun buildParameterSpec(type: TypeName, name: String, vararg modifiers: Modifier, configuration: ParameterSpecBuilder.() -> Unit): ParameterSpec
Builds new ParameterSpec from TypeName, by populating newly created ParameterSpecBuilder using provided configuration.
fun buildParameterSpec(type: Type, name: String, vararg modifiers: Modifier, configuration: ParameterSpecBuilder.() -> Unit): ParameterSpec
Builds new ParameterSpec from Type, by populating newly created ParameterSpecBuilder using provided configuration.
fun buildParameterSpec(type: KClass<*>, name: String, vararg modifiers: Modifier, configuration: ParameterSpecBuilder.() -> Unit): ParameterSpec
Builds new ParameterSpec from KClass, by populating newly created ParameterSpecBuilder using provided configuration.
classOf
Link copied to clipboard
inline fun String.classOf(simpleName: String, vararg simpleNames: String): ClassName
Returns a ClassName created from the given parts.
classTypeSpecOf
Link copied to clipboard
fun classTypeSpecOf(type: ClassName): TypeSpec
Builds new class TypeSpec from ClassName.
fun classTypeSpecOf(type: String): TypeSpec
Builds new class TypeSpec with name.
codeBlockOf
Link copied to clipboard
fun codeBlockOf(format: String, vararg args: Any): CodeBlock
Converts string to CodeBlock using formatted args.
edit
Link copied to clipboard
fun AnnotationSpec.Builder.edit(configuration: AnnotationSpecBuilder.() -> Unit): AnnotationSpec.Builder
Modify existing AnnotationSpec.Builder using provided configuration.
fun CodeBlock.Builder.edit(configuration: CodeBlockBuilder.() -> Unit): CodeBlock.Builder
Modify existing CodeBlock.Builder using provided configuration.
fun FieldSpec.Builder.edit(configuration: FieldSpecBuilder.() -> Unit): FieldSpec.Builder
Modify existing FieldSpec.Builder using provided configuration.
fun MethodSpec.Builder.edit(configuration: MethodSpecBuilder.() -> Unit): MethodSpec.Builder
Modify existing MethodSpec.Builder using provided configuration.
fun ParameterSpec.Builder.edit(configuration: ParameterSpecBuilder.() -> Unit): ParameterSpec.Builder
Modify existing ParameterSpec.Builder using provided configuration.
fun TypeSpec.Builder.edit(configuration: TypeSpecBuilder.() -> Unit): TypeSpec.Builder
Modify existing TypeSpec.Builder using provided configuration.
emptyConstructorMethodSpec
Link copied to clipboard
fun emptyConstructorMethodSpec(): MethodSpec
Builds new constructor MethodSpec.
enumTypeSpecOf
Link copied to clipboard
fun enumTypeSpecOf(type: ClassName): TypeSpec
Builds new enum TypeSpec from ClassName.
fun enumTypeSpecOf(type: String): TypeSpec
Builds new enum TypeSpec from name.
fieldSpecOf
Link copied to clipboard
inline fun <T> fieldSpecOf(name: String, vararg modifiers: Modifier): FieldSpec
Builds new FieldSpec from T supplying its name and modifiers.
fun fieldSpecOf(type: TypeName, name: String, vararg modifiers: Modifier): FieldSpec
Builds new FieldSpec from TypeName supplying its name and modifiers.
fun fieldSpecOf(type: Type, name: String, vararg modifiers: Modifier): FieldSpec
Builds new FieldSpec from Type supplying its name and modifiers.
fun fieldSpecOf(type: KClass<*>, name: String, vararg modifiers: Modifier): FieldSpec
Builds new FieldSpec from KClass supplying its name and modifiers.
interfaceTypeSpecOf
Link copied to clipboard
fun interfaceTypeSpecOf(type: ClassName): TypeSpec
Builds new interface TypeSpec from ClassName.
fun interfaceTypeSpecOf(type: String): TypeSpec
Builds new interface TypeSpec from name.
join
Link copied to clipboard
fun Iterable<CodeBlock>.join(separator: String): CodeBlock
Joins code blocks into a single CodeBlock, each separated by separator.
methodSpecOf
Link copied to clipboard
fun methodSpecOf(name: String): MethodSpec
Builds new MethodSpec with name.
parameterizedBy
Link copied to clipboard
inline fun ClassName.parameterizedBy(vararg typeArguments: TypeName): ParameterizedTypeName
Returns a ParameterizedTypeName applying TypeName arguments to ClassName.
fun ClassName.parameterizedBy(vararg typeArguments: Type = emptyArray()): ParameterizedTypeName
Returns a ParameterizedTypeName applying Type arguments to ClassName.
fun ClassName.parameterizedBy(vararg typeArguments: KClass<*> = emptyArray()): ParameterizedTypeName
Returns a ParameterizedTypeName applying KClass arguments to ClassName.
fun ClassName.parameterizedBy(typeArguments: Collection<TypeName>): ParameterizedTypeName
Returns a ParameterizedTypeName applying TypeName argument list to ClassName.
fun Class<*>.parameterizedBy(vararg typeArguments: TypeName = emptyArray()): ParameterizedTypeName
Returns a ParameterizedTypeName applying TypeName arguments to Class.
inline fun Class<*>.parameterizedBy(vararg typeArguments: Type): ParameterizedTypeName
Returns a ParameterizedTypeName applying Type arguments to Class.
fun Class<*>.parameterizedBy(vararg typeArguments: KClass<*> = emptyArray()): ParameterizedTypeName
Returns a ParameterizedTypeName applying KClass arguments to Class.
fun Class<*>.parameterizedBy(typeArguments: Collection<Type>): ParameterizedTypeName
Returns a ParameterizedTypeName applying Type argument list to Class.
fun KClass<*>.parameterizedBy(vararg typeArguments: TypeName = emptyArray()): ParameterizedTypeName
Returns a ParameterizedTypeName applying TypeName arguments to KClass.
fun KClass<*>.parameterizedBy(vararg typeArguments: Type = emptyArray()): ParameterizedTypeName
Returns a ParameterizedTypeName applying Type arguments to KClass.
inline fun KClass<*>.parameterizedBy(vararg typeArguments: KClass<*>): ParameterizedTypeName
Returns a ParameterizedTypeName applying KClass arguments to KClass.
fun KClass<*>.parameterizedBy(typeArguments: Collection<KClass<*>>): ParameterizedTypeName
Returns a ParameterizedTypeName applying KClass argument list to KClass.
parameterSpecOf
Link copied to clipboard
inline fun <T> parameterSpecOf(name: String, vararg modifiers: Modifier): ParameterSpec
Builds new ParameterSpec from T.
fun parameterSpecOf(type: TypeName, name: String, vararg modifiers: Modifier): ParameterSpec
Builds new ParameterSpec from TypeName.
fun parameterSpecOf(type: Type, name: String, vararg modifiers: Modifier): ParameterSpec
Builds new ParameterSpec from Type.
fun parameterSpecOf(type: KClass<*>, name: String, vararg modifiers: Modifier): ParameterSpec
Builds new ParameterSpec from KClass.
typeNameOf
Link copied to clipboard
inline fun <T> typeNameOf(): TypeName
Returns a TypeName equivalent to T.
typeVarBy
Link copied to clipboard
inline fun String.typeVarBy(vararg bounds: TypeName): TypeVariableName
Returns a TypeVariableName with TypeName bounds.
inline fun String.typeVarBy(vararg bounds: Type): TypeVariableName
Returns a TypeVariableName with Type bounds.
inline fun String.typeVarBy(vararg bounds: KClass<*>): TypeVariableName
Returns a TypeVariableName with KClass bounds.
typeVarOf
Link copied to clipboard
inline fun String.typeVarOf(): TypeVariableName
Returns a TypeVariableName without bounds.
wildcardSubtypeOf
Link copied to clipboard
inline fun TypeName.wildcardSubtypeOf(): WildcardTypeName
Returns a WildcardTypeName that represents an unknown type that extends TypeName.
inline fun Type.wildcardSubtypeOf(): WildcardTypeName
Returns a WildcardTypeName that represents an unknown type that extends Type.
inline fun KClass<*>.wildcardSubtypeOf(): WildcardTypeName
Returns a WildcardTypeName that represents an unknown type that extends KClass.
wildcardSupertypeOf
Link copied to clipboard
inline fun TypeName.wildcardSupertypeOf(): WildcardTypeName
Returns a WildcardTypeName that represents an unknown supertype of TypeName.
inline fun Type.wildcardSupertypeOf(): WildcardTypeName
Returns a WildcardTypeName that represents an unknown supertype of Type.
inline fun KClass<*>.wildcardSupertypeOf(): WildcardTypeName
Returns a WildcardTypeName that represents an unknown supertype of KClass.

Properties

ABSTRACT
Link copied to clipboard
val ABSTRACT: Modifier
BOOLEAN
Link copied to clipboard
val BOOLEAN: TypeName
BYTE
Link copied to clipboard
val BYTE: TypeName
CHAR
Link copied to clipboard
val CHAR: TypeName
DEFAULT
Link copied to clipboard
val DEFAULT: Modifier
DOUBLE
Link copied to clipboard
val DOUBLE: TypeName
FINAL
Link copied to clipboard
val FINAL: Modifier
FLOAT
Link copied to clipboard
val FLOAT: TypeName
INT
Link copied to clipboard
val INT: TypeName
LONG
Link copied to clipboard
val LONG: TypeName
NATIVE
Link copied to clipboard
val NATIVE: Modifier
OBJECT
Link copied to clipboard
val OBJECT: TypeName
PRIVATE
Link copied to clipboard
val PRIVATE: Modifier
PROTECTED
Link copied to clipboard
val PROTECTED: Modifier
PUBLIC
Link copied to clipboard
val PUBLIC: Modifier
SHORT
Link copied to clipboard
val SHORT: TypeName
STATIC
Link copied to clipboard
val STATIC: Modifier
STRICTFP
Link copied to clipboard
val STRICTFP: Modifier
SYNCHRONIZED
Link copied to clipboard
val SYNCHRONIZED: Modifier
TRANSIENT
Link copied to clipboard
val TRANSIENT: Modifier
VOID
Link copied to clipboard
val VOID: TypeName
VOLATILE
Link copied to clipboard
val VOLATILE: Modifier