Interface ParsedSchema

All Known Implementing Classes:
AvroSchema

public interface ParsedSchema
A parsed schema.

Implementations of this interface are instantiated by a corresponding SchemaProvider.

  • Field Details

  • Method Details

    • schemaType

      String schemaType()
      Returns the schema type.
      Returns:
      the schema type
    • name

      String name()
      Returns a name for the schema.
      Returns:
      the name, or null
    • canonicalString

      String canonicalString()
      Returns a canonical string representation of the schema.
      Returns:
      the canonical representation
    • formattedString

      default String formattedString(String format)
      Returns a formatted string according to a type-specific format.
      Returns:
      the formatted string
    • version

      Integer version()
      Returns the version of the schema if set.
      Returns:
      the version
    • references

      List<SchemaReference> references()
      Returns a list of schema references.
      Returns:
      the schema references
    • metadata

      Metadata metadata()
      Returns metadata.
      Returns:
      the metadata
    • ruleSet

      RuleSet ruleSet()
      Returns a rule set.
      Returns:
      the rule set
    • tags

      default Set<String> tags()
      Returns the set of tags used by the schema.
      Returns:
      the tags
    • inlineTags

      default Set<String> inlineTags()
      Returns the set of inline tags embedded in the schema.
      Returns:
      the tags
    • inlineTaggedEntities

      default Map<SchemaEntity,Set<String>> inlineTaggedEntities()
      Returns the inline tagged entities of the schema.
      Returns:
      a map of entity name to tags
    • copy

      ParsedSchema copy()
      Returns a copy of this schema.
      Returns:
      a copy of this schema
    • copy

      ParsedSchema copy(Integer version)
      Returns a copy of this schema, but with the given version.
      Parameters:
      version - the version
      Returns:
      a copy of this schema, but with the given version
    • copy

      ParsedSchema copy(Metadata metadata, RuleSet ruleSet)
      Returns a copy of this schema, but with the given metadata and rule set.
      Parameters:
      metadata - the metadata
      ruleSet - the rule set
      Returns:
      a copy of this schema, but with the given metadata and rule set
    • copy

      ParsedSchema copy(Map<SchemaEntity,Set<String>> tagsToAdd, Map<SchemaEntity,Set<String>> tagsToRemove)
      Returns a copy of this schema, but with the given tags.
      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
    • normalize

      default ParsedSchema normalize()
      Returns a normalized copy of this schema. Normalization generally ignores ordering when it is not significant.
      Returns:
      the normalized representation
    • validate

      default void validate()
      Validates the schema and ensures all references are resolved properly. Throws an exception if the schema is not valid.
    • validate

      default void validate(boolean strict)
      Validates the schema and ensures all references are resolved properly. Throws an exception if the schema is not valid.
    • isBackwardCompatible

      default List<String> isBackwardCompatible(CompatibilityPolicy policy, ParsedSchema previousSchema)
      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.

      Parameters:
      policy - the compatibility policy
      previousSchema - previous schema
      Returns:
      an empty list if this schema is backward compatible with the previous schema, otherwise the list of error messages
    • isBackwardCompatible

      List<String> isBackwardCompatible(ParsedSchema previousSchema)
      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.

      Parameters:
      previousSchema - previous schema
      Returns:
      an empty list if this schema is backward compatible with the previous schema, otherwise the list of error messages
    • isCompatible

      default List<String> isCompatible(CompatibilityLevel level, CompatibilityPolicy policy, List<ParsedSchemaHolder> previousSchemas)
      Checks the compatibility between this schema and the specified schemas.

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

      Parameters:
      level - the compatibility level
      policy - the compatibility policy
      previousSchemas - full schema history in chronological order
      Returns:
      an empty list if this schema is backward compatible with the previous schema, otherwise the list of error messages
    • isCompatible

      default List<String> isCompatible(CompatibilityLevel level, List<ParsedSchemaHolder> previousSchemas)
      Checks the compatibility between this schema and the specified schemas.

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

      Parameters:
      level - the compatibility level
      previousSchemas - full schema history in chronological order
      Returns:
      an empty list if this schema is backward compatible with the previous schema, otherwise the list of error messages
    • rawSchema

      Object rawSchema()
      Returns the underlying raw representation of the schema.
      Returns:
      the raw schema
    • hasTopLevelField

      default boolean hasTopLevelField(String field)
      Parameters:
      field - name of the field to check
      Returns:
      true, if the schema has field in its top level fields. false, otherwise.
    • deepEquals

      default boolean deepEquals(ParsedSchema schema)
      Deprecated.
      Returns whether the underlying raw representations are equivalent, ignoring version and references.
      Returns:
      whether the underlying raw representations are equivalent
    • equivalent

      default boolean equivalent(ParsedSchema schema)
      Returns whether the underlying raw representations are equivalent, ignoring version and references.
      Returns:
      whether the underlying raw representations are equivalent
    • fromJson

      default Object fromJson(com.fasterxml.jackson.databind.JsonNode json) throws IOException
      Throws:
      IOException
    • toJson

      default com.fasterxml.jackson.databind.JsonNode toJson(Object object) throws IOException
      Throws:
      IOException
    • copyMessage

      default Object copyMessage(Object message) throws IOException
      Throws:
      IOException
    • transformMessage

      default Object transformMessage(RuleContext ctx, FieldTransform transform, Object message) throws RuleException
      Throws:
      RuleException
    • getReservedFields

      default Set<String> getReservedFields()
    • canLookup

      default boolean canLookup(ParsedSchema prev, SchemaVersionFetcher fetcher)
      Returns whether the schema can be used to lookup the specified schema.
      Parameters:
      prev - the schema to lookup
      Returns:
      whether the schema can be used to lookup the specified schema