Class SchemaRegistry
java.lang.Object
org.j7m.middleware.codec.api.SchemaRegistry
Immutable allowlist of application-owned schemas; safe for concurrent codec calls.
-
Constructor Summary
ConstructorsConstructorDescriptionSchemaRegistry(List<SchemaDescriptor<?>> descriptors) Creates a registry and rejects duplicate registrations and incompatible adjacent versions. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckCompatible(SchemaDescriptor<?> a, SchemaDescriptor<?> b) Checks symmetric compatibility before decoding or registration, without invoking trusted functions.Finds an explicitly trusted class without class loading.forVersion(String id, int version) Finds an explicitly registered wire version.
-
Constructor Details
-
SchemaRegistry
Creates a registry and rejects duplicate registrations and incompatible adjacent versions. Adding/removing optional fields is compatible; field types and required fields cannot change.- Parameters:
descriptors- explicitly trusted schema definitions; may be empty- Throws:
IllegalArgumentException- for duplicate or incompatible schemas
-
-
Method Details
-
forType
Finds an explicitly trusted class without class loading.- Parameters:
type- exact registered class- Returns:
- descriptor or null when unregistered
-
forVersion
Finds an explicitly registered wire version.- Parameters:
id- stable schema identifierversion- positive version- Returns:
- descriptor or null when unregistered
-
checkCompatible
Checks symmetric compatibility before decoding or registration, without invoking trusted functions.- Parameters:
a- first descriptorb- second descriptor- Throws:
IllegalArgumentException- if fields are incompatible
-