wire-java-generator / com.squareup.wire.java / JavaGenerator

JavaGenerator

class JavaGenerator

Generates Java source code that matches proto definitions.

This can map type names from protocol buffers (like uint32, string, or squareup.protos.person.Person to the corresponding Java names (like int, java.lang.String, or com.squareup.protos.person.Person).

Functions

abstractAdapterName

fun abstractAdapterName(protoType: ProtoType): ClassName?

Returns the Java type of the abstract adapter class generated for a corresponding protoType. Returns null if protoType is not using a custom proto adapter.

generateAdapterForCustomType

fun generateAdapterForCustomType(type: Type): TypeSpec

Returns a standalone adapter for type.

generateEnum

fun generateEnum(type: EnumType): TypeSpec

generateMessage

fun generateMessage(type: MessageType): TypeSpec

generateOptionType

fun generateOptionType(extend: Extend, field: Field): TypeSpec?

generateType

fun generateType(type: Type): TypeSpec

Returns the generated code for type, which may be a top-level or a nested type.

generatedTypeName

fun generatedTypeName(type: Type): ClassName

Returns the full name of the class generated for type.

fun generatedTypeName(field: Field): ClassName

Returns the full name of the class generated for field.

get

static fun get(schema: Schema): JavaGenerator

isEnum

fun isEnum(type: ProtoType): Boolean

schema

fun schema(): Schema

typeName

fun typeName(protoType: ProtoType): TypeName

Returns the Java type for protoType.

withAndroid

fun withAndroid(emitAndroid: Boolean): JavaGenerator

withAndroidAnnotations

fun withAndroidAnnotations(emitAndroidAnnotations: Boolean): JavaGenerator

withCompact

fun withCompact(emitCompact: Boolean): JavaGenerator

withOptions

fun withOptions(emitDeclaredOptions: Boolean, emitAppliedOptions: Boolean): JavaGenerator

withProfile

fun withProfile(profile: Profile): JavaGenerator