Schema

class Schema

A collection of .proto files that describe a set of messages. A schema is linked: each field's type name is resolved to the corresponding type definition.

Use SchemaLoader to load a schema from source files.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun getField(protoMember: ProtoMember): Field?

Returns the field for protoMember, or null if this schema defines no such field.

fun getField(protoType: ProtoType, memberName: String): Field?

Returns the field for protoType and memberName, or null if this schema defines no such field.

fun getField(typeName: String, memberName: String): Field?

Returns the field with the fully qualified typeName and memberName, or null if this schema defines no such field.

Link copied to clipboard
fun getService(protoType: ProtoType): Service?

Returns the service for protoType, or null if this schema defines no such service.

Returns the service with the fully qualified name name, or null if this schema defines no such service.

Link copied to clipboard
fun getType(protoType: ProtoType): Type?

Returns the type for protoType, or null if this schema defines no such type.

fun getType(name: String): Type?

Returns the type with the fully qualified name name, or null if this schema defines no such type.

Link copied to clipboard
Link copied to clipboard
fun protoAdapter(typeName: String, includeUnknown: Boolean): ProtoAdapter<Any>

Returns a wire adapter for the message or enum type named typeName. The returned type adapter doesn't have model classes to encode and decode from, so instead it uses scalar types (String, ByteString, Integer, etc.), maps, lists, and corresponding classes to proto3 types (e.g. Instant for google.prptobuf.Timestamp.) It can both encode and decode these objects. Map keys are field names.

Link copied to clipboard
fun protoFile(protoType: ProtoType): ProtoFile?

Returns the proto file containing this protoType, or null if there isn't such file.

fun protoFile(path: Path): ProtoFile?

Returns the proto file at path, or null if this schema has no such file.

Link copied to clipboard
fun prune(pruningRules: PruningRules): Schema

Returns a copy of this schema that retains only the types and services selected by pruningRules, plus their transitive dependencies.