Interface ParsedSchema
- All Known Implementing Classes:
AvroSchema
public interface ParsedSchema
A parsed schema.
Implementations of this interface are instantiated by a corresponding
SchemaProvider.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanLookup(ParsedSchema prev, SchemaVersionFetcher fetcher) Returns whether the schema can be used to lookup the specified schema.Returns a canonical string representation of the schema.copy()Returns a copy of this schema.Returns a copy of this schema, but with the given metadata and rule set.Returns a copy of this schema, but with the given version.copy(Map<SchemaEntity, Set<String>> tagsToAdd, Map<SchemaEntity, Set<String>> tagsToRemove) Returns a copy of this schema, but with the given tags.default ObjectcopyMessage(Object message) default booleandeepEquals(ParsedSchema schema) Deprecated.default booleanequivalent(ParsedSchema schema) Returns whether the underlying raw representations are equivalent, ignoring version and references.default StringformattedString(String format) Returns a formatted string according to a type-specific format.default ObjectfromJson(com.fasterxml.jackson.databind.JsonNode json) default booleanhasTopLevelField(String field) default Map<SchemaEntity,Set<String>> Returns the inline tagged entities of the schema.Returns the set of inline tags embedded in the schema.isBackwardCompatible(CompatibilityPolicy policy, ParsedSchema previousSchema) Checks the backward compatibility between this schema and the specified schema.isBackwardCompatible(ParsedSchema previousSchema) Checks the backward compatibility between this schema and the specified schema.isCompatible(CompatibilityLevel level, CompatibilityPolicy policy, List<ParsedSchemaHolder> previousSchemas) Checks the compatibility between this schema and the specified schemas.isCompatible(CompatibilityLevel level, List<ParsedSchemaHolder> previousSchemas) Checks the compatibility between this schema and the specified schemas.metadata()Returns metadata.name()Returns a name for the schema.default ParsedSchemaReturns a normalized copy of this schema.Returns the underlying raw representation of the schema.Returns a list of schema references.ruleSet()Returns a rule set.Returns the schema type.tags()Returns the set of tags used by the schema.default com.fasterxml.jackson.databind.JsonNodedefault ObjecttransformMessage(RuleContext ctx, FieldTransform transform, Object message) default voidvalidate()Validates the schema and ensures all references are resolved properly.default voidvalidate(boolean strict) Validates the schema and ensures all references are resolved properly.version()Returns the version of the schema if set.
-
Field Details
-
RESERVED
- See Also:
-
-
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
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
Returns the set of tags used by the schema.- Returns:
- the tags
-
inlineTags
Returns the set of inline tags embedded in the schema.- Returns:
- the tags
-
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
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
Returns a copy of this schema, but with the given metadata and rule set.- Parameters:
metadata- the metadataruleSet- 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
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
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 policypreviousSchema- previous schema- Returns:
- an empty list if this schema is backward compatible with the previous schema, otherwise the list of error messages
-
isBackwardCompatible
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 levelpolicy- the compatibility policypreviousSchemas- 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 levelpreviousSchemas- 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
- Parameters:
field- name of the field to check- Returns:
- true, if the schema has field in its top level fields. false, otherwise.
-
deepEquals
Deprecated.useequivalent(ParsedSchema)insteadReturns whether the underlying raw representations are equivalent, ignoring version and references.- Returns:
- whether the underlying raw representations are equivalent
-
equivalent
Returns whether the underlying raw representations are equivalent, ignoring version and references.- Returns:
- whether the underlying raw representations are equivalent
-
fromJson
- Throws:
IOException
-
toJson
- Throws:
IOException
-
copyMessage
- Throws:
IOException
-
transformMessage
default Object transformMessage(RuleContext ctx, FieldTransform transform, Object message) throws RuleException - Throws:
RuleException
-
getReservedFields
-
canLookup
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
-
equivalent(ParsedSchema)instead