Class LogicalTypeChecker

java.lang.Object
io.confluent.kafka.schemaregistry.type.logical.policy.LogicalTypeChecker

public final class LogicalTypeChecker extends Object
Entry point for checking a LogicalType against a downstream consumer's rules.

validate(io.confluent.kafka.schemaregistry.type.logical.policy.LogicalTypeChecker.Mode, io.confluent.kafka.schemaregistry.type.logical.LogicalType) takes one schema and asks whether the consumer can use it at all. compare(io.confluent.kafka.schemaregistry.type.logical.policy.LogicalTypeChecker.Mode, io.confluent.kafka.schemaregistry.type.logical.LogicalType, io.confluent.kafka.schemaregistry.type.logical.LogicalType) takes two and asks whether the change between them is safe. The rules live in ValidityChecker and CompatibilityChecker respectively; read those for the rules, call this for the API.

A caller registering a schema needs both. Neither subsumes the other: a schema whose decimal precision exceeds what the consumer supports is unusable whether or not it changed, so a pairwise check alone lets it through on a first registration and on any later one that leaves the offending column untouched.


 ValidityResult validity = LogicalTypeChecker.validate(mode, update);
 CompatibilityResult compatibility = previous == null
     ? CompatibilityResult.compatible()
     : LogicalTypeChecker.compare(mode, previous, update);
 if (!validity.isValid() || !compatibility.isCompatible()) {
   // reject, reporting validity.describe() and compatibility.describe()
 }
 

Both results collect every finding rather than stopping at the first.