Class LogicalSchemaProvider

java.lang.Object
io.confluent.kafka.schemaregistry.AbstractSchemaProvider
io.confluent.kafka.schemaregistry.type.logical.LogicalSchemaProvider
All Implemented Interfaces:
SchemaProvider, org.apache.kafka.common.Configurable
Direct Known Subclasses:
LogicalAvroSchemaProvider, LogicalJsonSchemaProvider, LogicalProtobufSchemaProvider

public class LogicalSchemaProvider extends AbstractSchemaProvider
A schema provider that also accepts schemas written as logical types DDL, converting them to the native format of the provider it wraps.

Native-first, the same rule the registry applies: the body is handed to the wrapped provider first, and only a body that provider rejects is tried as DDL. So a native schema always wins, and a body that is neither reports the native error rather than a misleading DDL one.

Note that this converts locally. A caller that wants the registry to do the conversion -- so that what it stores is decided server-side -- must send the DDL itself rather than the schema this returns.

  • Constructor Details

    • LogicalSchemaProvider

      public LogicalSchemaProvider(SchemaProvider delegate)
  • Method Details

    • isLogical

      public static boolean isLogical(String text)
      Returns whether text is logical types DDL, without converting it.
    • schemaType

      public String schemaType()
    • isSubjectDependent

      public boolean isSubjectDependent(Schema schema)
      A DDL body reads the subject, to name a root the script leaves anonymous. A native body is handed to the delegate untouched, so whether it reads the subject is the delegate's to say -- a wrapped provider that depends on the subject must not lose that by being wrapped.
    • configure

      public void configure(Map<String,?> configs)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
      Specified by:
      configure in interface SchemaProvider
      Overrides:
      configure in class AbstractSchemaProvider
    • parseSchemaOrElseThrow

      public ParsedSchema parseSchemaOrElseThrow(Schema schema, boolean validateAsNew, boolean normalize)
    • resolveReferences

      protected Map<String,String> resolveReferences(Schema schema, boolean validateAsNew)
      Overrides:
      resolveReferences in class AbstractSchemaProvider