Interface SchemaParser<S,​U>

  • Type Parameters:
    S - The type of schema being parsed
    All Known Implementing Classes:
    JsonSchemaParser

    public interface SchemaParser<S,​U>
    Represents a generic schema parser interface.
    • Method Detail

      • parse

        ParsedSchema<S> parse​(byte[] rawSchemaBytes,
                              Map<String,​byte[]> references)
        Parses a raw schema from a byte array, considering any referenced schemas.
        Parameters:
        rawSchemaBytes - Raw schema content as byte array.
        references - A map of referenced schemas, where the key is the reference name and the value is the raw schema content as a byte array.
        Returns:
        A parsed schema representation.
      • getSchemaFromData

        ParsedSchema<S> getSchemaFromData​(Record<U> data)
        Extracts the schema from a given data record. This method is particularly useful for artifact types like AVRO, where the schema can be extracted directly from the Java object.
        Parameters:
        data - The record from which to extract the schema.
        Returns:
        A ParsedSchema containing both the raw schema (as bytes) and the parsed schema.
      • getSchemaFromLocation

        default ParsedSchema<S> getSchemaFromLocation​(String location)
        Retrieves a schema from a specified location in the Java classpath. This method allows loading schemas from resources that are available on the classpath.
        Parameters:
        location - The resource path on the classpath from which to load the schema.
        Returns:
        A ParsedSchema containing both the raw schema (as bytes) and the parsed schema.
        Throws:
        UnsupportedOperationException - if the implementation does not support retrieving schemas from classpath resources.
      • supportsGetSchemaFromLocation

        default boolean supportsGetSchemaFromLocation()
        Flag that indicates if getSchemaFromLocation(String) is implemented or not. When true, the parser can retrieve schemas from resources on the Java classpath.
        Returns:
        true if getSchemaFromLocation(String) is implemented, false otherwise.
      • artifactType

        String artifactType()
        Retrieves the artifact type of the schema parser.
        Returns:
        The artifact type of the schema parser.