SchemaHelper

object SchemaHelper
class Object
trait Matchable
class Any

Value members

Concrete methods

def createSafeUnion(schemas: Schema*): Schema

Creates a union schema type, with nested unions extracted, and duplicate nulls stripped.

Creates a union schema type, with nested unions extracted, and duplicate nulls stripped.

Union schemas can't contain other union schemas as a direct child, so whenever we create a union, we need to check if our children are unions and flatten

For example, an Option[SealedTrait], would result in a union of a union, so this must be flattened into a single union.

def extractEitherLeftSchema(schema: Schema): Schema

Returns the subschema used for a Left in an Either.

Returns the subschema used for a Left in an Either.

def extractEitherRightSchema(schema: Schema): Schema

Returns the subschema used for a Right in an Either.

Returns the subschema used for a Right in an Either.

def extractTraitSubschema(fullName: String, union: Schema): Schema

Given the full name of a record, locates the appropriate sub schema from the given union.

Given the full name of a record, locates the appropriate sub schema from the given union.

def mapNames(schema: Schema, mapper: FieldMapper): Schema
def matchPrimitiveName(fullName: String): Option[Schema]
def moveDefaultToHead(schema: Schema, default: Any): Schema

Requires a UNION schema and will attempt to find a subschema that matches the default value type. If one matches it will move that schema to the head, as required by the spec.

Requires a UNION schema and will attempt to find a subschema that matches the default value type. If one matches it will move that schema to the head, as required by the spec.

def moveNullToHead(schema: Schema): Schema

Requires a UNION schema and will move the null schema to the head if it exists. Otherwise returns the UNION as is.

Requires a UNION schema and will move the null schema to the head if it exists. Otherwise returns the UNION as is.

def overrideNamespace(schema: Schema, namespace: String): Schema

Takes an Avro schema, and overrides the namespace of that schema with the given namespace.

Takes an Avro schema, and overrides the namespace of that schema with the given namespace.

def setError(schema: Schema): Schema
def validateEitherSchema(schema: Schema): Unit

Throws if the given schema is not suitable for use in an either.

Throws if the given schema is not suitable for use in an either.