com.fasterxml.jackson.dataformat.avro.schema

## Class AvroSchemaHelper

- java.lang.Object
- - com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaHelper

-     public abstract class AvroSchemaHelper
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `AVRO_SCHEMA_PROP_CLASS` Constant used by native Avro Schemas for indicating more specific physical class of a value; referenced indirectly to reduce direct dependencies to the standard avro library.
    `static String` | `AVRO_SCHEMA_PROP_ELEMENT_CLASS` Constant used by native Avro Schemas for indicating more specific physical class of a array element; referenced indirectly to reduce direct dependencies to the standard avro library.
    `static String` | `AVRO_SCHEMA_PROP_KEY_CLASS` Constant used by native Avro Schemas for indicating more specific physical class of a map key; referenced indirectly to reduce direct dependencies to the standard avro library.
    `protected static Set<Class<?>>` | `STRINGABLE_CLASSES` Default stringable classes

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AvroSchemaHelper()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.apache.avro.Schema` | `addAlias(org.apache.avro.Schema schema, com.fasterxml.jackson.databind.BeanDescription bean)` Looks for `@AvroAlias` on `bean` and adds it to `schema` if it exists
    `static org.apache.avro.Schema` | `anyNumberSchema()`
    `static org.apache.avro.Schema` | `createEnumSchema(com.fasterxml.jackson.databind.BeanDescription bean, List<String> values)` Constructs a new enum schema
    `static String` | `getFullName(org.apache.avro.Schema schema)` Returns the full name of a schema; This is similar to `Schema.getFullName()`, except that it properly handles namespaces for nested classes.
    `protected static String` | `getName(com.fasterxml.jackson.databind.JavaType type)`
    `protected static String` | `getNamespace(com.fasterxml.jackson.databind.JavaType type)`
    `static String` | `getTypeId(Class<?> type)` Returns the Avro type ID for a given type
    `static String` | `getTypeId(com.fasterxml.jackson.databind.JavaType type)`
    `static String` | `getTypeId(org.apache.avro.Schema schema)` Returns the type ID for this schema, or `null` if none is present.
    `static org.apache.avro.Schema` | `initializeRecordSchema(com.fasterxml.jackson.databind.BeanDescription bean)` Initializes a record schema with metadata from the given class; this schema is returned in a non-finalized state, and still needs to have fields added to it.
    `static boolean` | `isStringable(com.fasterxml.jackson.databind.introspect.AnnotatedClass type)` Checks if a given type is "Stringable", that is one of the default `STRINGABLE_CLASSES`, is an `Enum`, or is annotated with `@Stringable` and has a constructor that takes a single string argument capable of deserializing the output of its `toString()` method.
    `static org.apache.avro.Schema` | `numericAvroSchema(com.fasterxml.jackson.core.JsonParser.NumberType type)`
    `static org.apache.avro.Schema` | `numericAvroSchema(com.fasterxml.jackson.core.JsonParser.NumberType type, com.fasterxml.jackson.databind.JavaType hint)`
    `static org.apache.avro.Schema` | `parseJsonSchema(String json)` Parses a JSON-formatted representation of a schema
    `static org.apache.avro.Schema` | `simpleSchema(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes type, com.fasterxml.jackson.databind.JavaType hint)`
    `static org.apache.avro.Schema` | `stringableKeyMapSchema(com.fasterxml.jackson.databind.JavaType mapType, com.fasterxml.jackson.databind.JavaType keyType, org.apache.avro.Schema valueSchema)`
    `protected static <T> T` | `throwUnsupported()`
    `static org.apache.avro.Schema` | `typedSchema(org.apache.avro.Schema.Type nativeType, com.fasterxml.jackson.databind.JavaType javaType)` Helper method for constructing type-tagged "native" Avro Schema instance.
    `protected static org.apache.avro.Schema` | `unionWithNull(org.apache.avro.Schema otherSchema)`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### AVRO_SCHEMA_PROP_CLASS

          public static final String AVRO_SCHEMA_PROP_CLASS

      Constant used by native Avro Schemas for indicating more specific physical class of a value; referenced indirectly to reduce direct dependencies to the standard avro library.
      Since:
        2.8.7
      See Also:
        Constant Field Values

    - #### AVRO_SCHEMA_PROP_KEY_CLASS

          public static final String AVRO_SCHEMA_PROP_KEY_CLASS

      Constant used by native Avro Schemas for indicating more specific physical class of a map key; referenced indirectly to reduce direct dependencies to the standard avro library.
      Since:
        2.8.7
      See Also:
        Constant Field Values

    - #### AVRO_SCHEMA_PROP_ELEMENT_CLASS

          public static final String AVRO_SCHEMA_PROP_ELEMENT_CLASS

      Constant used by native Avro Schemas for indicating more specific physical class of a array element; referenced indirectly to reduce direct dependencies to the standard avro library.
      Since:
        2.8.8
      See Also:
        Constant Field Values

    - #### STRINGABLE_CLASSES

          protected static final Set<Class<?>> STRINGABLE_CLASSES

      Default stringable classes
      Since:
        2.8.7

  - ### Constructor Detail

    - #### AvroSchemaHelper

          public AvroSchemaHelper()

  - ### Method Detail

    - #### isStringable

          public static boolean isStringable(com.fasterxml.jackson.databind.introspect.AnnotatedClass type)

      Checks if a given type is "Stringable", that is one of the default `STRINGABLE_CLASSES`, is an `Enum`, or is annotated with `@Stringable` and has a constructor that takes a single string argument capable of deserializing the output of its `toString()` method.
      Parameters:
        `type` - Type to check if it can be serialized to a Avro string schema
      Returns:
        `true` if it can be stored in a string schema, otherwise `false`

    - #### getNamespace

          protected static String getNamespace(com.fasterxml.jackson.databind.JavaType type)

    - #### getName

          protected static String getName(com.fasterxml.jackson.databind.JavaType type)

    - #### unionWithNull

          protected static org.apache.avro.Schema unionWithNull(org.apache.avro.Schema otherSchema)

    - #### simpleSchema

          public static org.apache.avro.Schema simpleSchema(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes type,
                                                            com.fasterxml.jackson.databind.JavaType hint)

    - #### numericAvroSchema

          public static org.apache.avro.Schema numericAvroSchema(com.fasterxml.jackson.core.JsonParser.NumberType type)

    - #### numericAvroSchema

          public static org.apache.avro.Schema numericAvroSchema(com.fasterxml.jackson.core.JsonParser.NumberType type,
                                                                 com.fasterxml.jackson.databind.JavaType hint)

    - #### typedSchema

          public static org.apache.avro.Schema typedSchema(org.apache.avro.Schema.Type nativeType,
                                                           com.fasterxml.jackson.databind.JavaType javaType)

      Helper method for constructing type-tagged "native" Avro Schema instance.
      Since:
        2.8.7

    - #### anyNumberSchema

          public static org.apache.avro.Schema anyNumberSchema()

    - #### stringableKeyMapSchema

          public static org.apache.avro.Schema stringableKeyMapSchema(com.fasterxml.jackson.databind.JavaType mapType,
                                                                      com.fasterxml.jackson.databind.JavaType keyType,
                                                                      org.apache.avro.Schema valueSchema)

    - #### throwUnsupported

          protected static <T> T throwUnsupported()

    - #### initializeRecordSchema

          public static org.apache.avro.Schema initializeRecordSchema(com.fasterxml.jackson.databind.BeanDescription bean)

      Initializes a record schema with metadata from the given class; this schema is returned in a non-finalized state, and still needs to have fields added to it.

    - #### parseJsonSchema

          public static org.apache.avro.Schema parseJsonSchema(String json)

      Parses a JSON-formatted representation of a schema

    - #### createEnumSchema

          public static org.apache.avro.Schema createEnumSchema(com.fasterxml.jackson.databind.BeanDescription bean,
                                                                List<String> values)

      Constructs a new enum schema
      Parameters:
        `bean` - Enum type to use for name / description / namespace
        `values` - List of enum names
      Returns:
        An `ENUM` schema.

    - #### addAlias

          public static org.apache.avro.Schema addAlias(org.apache.avro.Schema schema,
                                                        com.fasterxml.jackson.databind.BeanDescription bean)

      Looks for `@AvroAlias` on `bean` and adds it to `schema` if it exists
      Parameters:
        `schema` - Schema to which the alias should be added
        `bean` - Bean to inspect for type aliases
      Returns:
        `schema`, possibly with an alias added

    - #### getTypeId

          public static String getTypeId(com.fasterxml.jackson.databind.JavaType type)

    - #### getTypeId

          public static String getTypeId(Class<?> type)

      Returns the Avro type ID for a given type

    - #### getTypeId

          public static String getTypeId(org.apache.avro.Schema schema)

      Returns the type ID for this schema, or `null` if none is present.

    - #### getFullName

          public static String getFullName(org.apache.avro.Schema schema)

      Returns the full name of a schema; This is similar to `Schema.getFullName()`, except that it properly handles namespaces for nested classes. (`package.name.ClassName$NestedClassName` instead of `package.name.ClassName$.NestedClassName`)

Copyright © 2019 FasterXML. All rights reserved.