public final class ProtoCodecs

  1. Object
  2. ProtoCodecs

Runtime registry that wires @ProtoMessage classes to their build-time-generated ProtoCodecs. The generated cn1app.ProtoBootstrap calls register(Class, ProtoCodec) for every protobuf message in the project; generated gRPC client impls and per-class codecs call lookup(Class) to resolve nested-message types at runtime.

Mirrors RestClients.

Methods

public static <T> void register(Class<T> type, ProtoCodec<T> codec)Registers a codec for a @ProtoMessage class.
public static <T> ProtoCodec<T> lookup(Class<T> type)Returns the codec previously registered for type.

Inherited methods

Method details

register

public static <T> void register(Class<T> type, ProtoCodec<T> codec)
Registers a codec for a @ProtoMessage class. Called from the generated cn1app.ProtoBootstrap.

lookup

public static <T> ProtoCodec<T> lookup(Class<T> type)
Returns the codec previously registered for type. Throws IllegalStateException when no codec is registered so the failure is loud rather than silent (typical cause: the generated cn1app.ProtoBootstrap hasn’t run, or type isn’t annotated @ProtoMessage).