Class AvroSchema

java.lang.Object
io.confluent.kafka.schemaregistry.avro.AvroSchema
All Implemented Interfaces:
ParsedSchema

public class AvroSchema extends Object implements ParsedSchema
  • Field Details

  • Constructor Details

  • Method Details

    • copy

      public AvroSchema copy()
      Description copied from interface: ParsedSchema
      Returns a copy of this schema.
      Specified by:
      copy in interface ParsedSchema
      Returns:
      a copy of this schema
    • copy

      public AvroSchema copy(Integer version)
      Description copied from interface: ParsedSchema
      Returns a copy of this schema, but with the given version.
      Specified by:
      copy in interface ParsedSchema
      Parameters:
      version - the version
      Returns:
      a copy of this schema, but with the given version
    • copy

      public AvroSchema copy(Metadata metadata, RuleSet ruleSet)
      Description copied from interface: ParsedSchema
      Returns a copy of this schema, but with the given metadata and rule set.
      Specified by:
      copy in interface ParsedSchema
      Parameters:
      metadata - the metadata
      ruleSet - the rule set
      Returns:
      a copy of this schema, but with the given metadata and rule set
    • copy

      public ParsedSchema copy(Map<SchemaEntity,Set<String>> tagsToAdd, Map<SchemaEntity,Set<String>> tagsToRemove)
      Description copied from interface: ParsedSchema
      Returns a copy of this schema, but with the given tags.
      Specified by:
      copy in interface ParsedSchema
      Parameters:
      tagsToAdd - map of tags to add to the schema record or field, where the key is the entity and the value is the set of tags. If the tag already exists, do nothing.
      tagsToRemove - map of tags to remove from the schema record or field, where the key is the entity and the value is the set of tags. If the tag does not exist, do nothing.
      Returns:
      a copy of this schema, but with the given tags
    • getParser

      protected org.apache.avro.Schema.Parser getParser()
    • rawSchema

      public org.apache.avro.Schema rawSchema()
      Description copied from interface: ParsedSchema
      Returns the underlying raw representation of the schema.
      Specified by:
      rawSchema in interface ParsedSchema
      Returns:
      the raw schema
    • hasTopLevelField

      public boolean hasTopLevelField(String field)
      Specified by:
      hasTopLevelField in interface ParsedSchema
      Parameters:
      field - name of the field to check
      Returns:
      true, if the schema has field in its top level fields. false, otherwise.
    • schemaType

      public String schemaType()
      Description copied from interface: ParsedSchema
      Returns the schema type.
      Specified by:
      schemaType in interface ParsedSchema
      Returns:
      the schema type
    • name

      public String name()
      Description copied from interface: ParsedSchema
      Returns a name for the schema.
      Specified by:
      name in interface ParsedSchema
      Returns:
      the name, or null
    • canonicalString

      public String canonicalString()
      Description copied from interface: ParsedSchema
      Returns a canonical string representation of the schema.
      Specified by:
      canonicalString in interface ParsedSchema
      Returns:
      the canonical representation
    • formattedString

      public String formattedString(String format)
      Description copied from interface: ParsedSchema
      Returns a formatted string according to a type-specific format.
      Specified by:
      formattedString in interface ParsedSchema
      Returns:
      the formatted string
    • version

      public Integer version()
      Description copied from interface: ParsedSchema
      Returns the version of the schema if set.
      Specified by:
      version in interface ParsedSchema
      Returns:
      the version
    • references

      public List<SchemaReference> references()
      Description copied from interface: ParsedSchema
      Returns a list of schema references.
      Specified by:
      references in interface ParsedSchema
      Returns:
      the schema references
    • resolvedReferences

      public Map<String,String> resolvedReferences()
    • metadata

      public Metadata metadata()
      Description copied from interface: ParsedSchema
      Returns metadata.
      Specified by:
      metadata in interface ParsedSchema
      Returns:
      the metadata
    • ruleSet

      public RuleSet ruleSet()
      Description copied from interface: ParsedSchema
      Returns a rule set.
      Specified by:
      ruleSet in interface ParsedSchema
      Returns:
      the rule set
    • isNew

      public boolean isNew()
    • normalize

      public AvroSchema normalize()
      Description copied from interface: ParsedSchema
      Returns a normalized copy of this schema. Normalization generally ignores ordering when it is not significant.
      Specified by:
      normalize in interface ParsedSchema
      Returns:
      the normalized representation
    • isBackwardCompatible

      public List<String> isBackwardCompatible(ParsedSchema previousSchema)
      Description copied from interface: ParsedSchema
      Checks the backward compatibility between this schema and the specified schema.

      Custom providers may choose to modify this schema during this check, to ensure that it is compatible with the specified schema.

      Specified by:
      isBackwardCompatible in interface ParsedSchema
      Parameters:
      previousSchema - previous schema
      Returns:
      an empty list if this schema is backward compatible with the previous schema, otherwise the list of error messages
    • equivalent

      public boolean equivalent(ParsedSchema schema)
      Returns whether the underlying raw representations are equivalent, ignoring version and references.
      Specified by:
      equivalent in interface ParsedSchema
      Returns:
      whether the underlying raw representations are equivalent
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromJson

      public Object fromJson(com.fasterxml.jackson.databind.JsonNode json) throws IOException
      Specified by:
      fromJson in interface ParsedSchema
      Throws:
      IOException
    • toJson

      public com.fasterxml.jackson.databind.JsonNode toJson(Object message) throws IOException
      Specified by:
      toJson in interface ParsedSchema
      Throws:
      IOException
    • copyMessage

      public Object copyMessage(Object message)
      Specified by:
      copyMessage in interface ParsedSchema
    • transformMessage

      public Object transformMessage(RuleContext ctx, FieldTransform transform, Object message) throws RuleException
      Specified by:
      transformMessage in interface ParsedSchema
      Throws:
      RuleException
    • inlineTags

      public Set<String> inlineTags()
      Description copied from interface: ParsedSchema
      Returns the set of inline tags embedded in the schema.
      Specified by:
      inlineTags in interface ParsedSchema
      Returns:
      the tags
    • inlineTaggedEntities

      public Map<SchemaEntity,Set<String>> inlineTaggedEntities()
      Description copied from interface: ParsedSchema
      Returns the inline tagged entities of the schema.
      Specified by:
      inlineTaggedEntities in interface ParsedSchema
      Returns:
      a map of entity name to tags