com.fasterxml.jackson.dataformat.avro

## Class AvroSchema

- java.lang.Object
- - com.fasterxml.jackson.dataformat.avro.AvroSchema

- All Implemented Interfaces:
    com.fasterxml.jackson.core.FormatSchema

      public class AvroSchema
      extends Object
      implements com.fasterxml.jackson.core.FormatSchema

  Wrapper for Schema information needed to encode and decode Avro-format data.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AtomicReference<AvroStructureReader>` | `_reader` Lazily instantiated value reader for this schema.
    `protected org.apache.avro.Schema` | `_writerSchema` Schema that was used for writing the data to decode; for simple instance used for reading as well (reader schema).
    `static String` | `TYPE_ID` Format type id used by Jackson components to refer to Avro Format.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AvroSchema(org.apache.avro.Schema asch)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected AvroStructureReader` | `_constructReader()`
    `boolean` | `equals(Object o)`
    `org.apache.avro.Schema` | `getAvroSchema()` Accessor for "writer schema" contained in this instance.
    `AvroStructureReader` | `getReader()`
    `String` | `getSchemaType()`
    `int` | `hashCode()`
    `String` | `toString()`
    `AvroSchema` | `withReaderSchema(AvroSchema readerSchema)` Method that will consider this schema instance (used as so-called "Writer Schema"), and specified "Reader Schema" instance, and will either construct a new schema with appropriate translations, to use for reading (if reader and writer schemas are not same); or, if schemas are the same, return `this`.
    `AvroSchema` | `withUnsafeReaderSchema(AvroSchema readerSchema)` Similar to `withReaderSchema(com.fasterxml.jackson.dataformat.avro.AvroSchema)` but will NOT verify compatibility of schemas: this means that certain problems (such as missing default value for a newly added field) that would be caught at construction may be surfaced later when using schema.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TYPE_ID

          public static final String TYPE_ID

      Format type id used by Jackson components to refer to Avro Format.
      See Also:
        Constant Field Values

    - #### _writerSchema

          protected final org.apache.avro.Schema _writerSchema

      Schema that was used for writing the data to decode; for simple instance used for reading as well (reader schema).

    - #### _reader

          protected final AtomicReference<AvroStructureReader> _reader

      Lazily instantiated value reader for this schema.

  - ### Constructor Detail

    - #### AvroSchema

          public AvroSchema(org.apache.avro.Schema asch)

  - ### Method Detail

    - #### withReaderSchema

          public AvroSchema withReaderSchema(AvroSchema readerSchema)
                                      throws com.fasterxml.jackson.core.JsonProcessingException

      Method that will consider this schema instance (used as so-called "Writer Schema"), and specified "Reader Schema" instance, and will either construct a new schema with appropriate translations, to use for reading (if reader and writer schemas are not same); or, if schemas are the same, return `this`.

      Note that neither `this` instance nor `readerSchema` is ever modified: if an altered version is needed, a new schema object will be constructed.

      NOTE: this is a relatively expensive operation due to validation (although significant part of cost is deferred until the first call to `getReader()`) so it is recommended that these instances are reused whenever possible.

      Parameters:
        `readerSchema` - "Reader Schema" to use (in Avro terms): schema that specified how reader wants to see the data; specifies part of translation needed along with this schema (which would be "Writer Schema" in Avro terms).
      Throws:
        `com.fasterxml.jackson.core.JsonProcessingException` - If given reader schema is incompatible with (writer-) schema this instance was constructed with,
      Since:
        2.9

    - #### withUnsafeReaderSchema

          public AvroSchema withUnsafeReaderSchema(AvroSchema readerSchema)
                                            throws com.fasterxml.jackson.core.JsonProcessingException

      Similar to `withReaderSchema(com.fasterxml.jackson.dataformat.avro.AvroSchema)` but will NOT verify compatibility of schemas: this means that certain problems (such as missing default value for a newly added field) that would be caught at construction may be surfaced later when using schema. This is, however, sometimes necessary to work around potential BUT NOT ACTUAL problems.
      Throws:
        `com.fasterxml.jackson.core.JsonProcessingException`
      Since:
        2.9

    - #### getSchemaType

          public String getSchemaType()

      Specified by:
        `getSchemaType` in interface `com.fasterxml.jackson.core.FormatSchema`

    - #### getAvroSchema

          public org.apache.avro.Schema getAvroSchema()

      Accessor for "writer schema" contained in this instance.

    - #### getReader

          public AvroStructureReader getReader()

    - #### _constructReader

          protected AvroStructureReader _constructReader()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

Copyright © 2017 FasterXML. All rights reserved.