AvroName

com.sksamuel.avro4s.AvroName
case class AvroName(name: String) extends AvroNameable

AvroName allows the name used by Avro to be different from what is defined in code.

For example, if a case class defines a field z, such as case class Foo(z: String) then normally this will be serialized as an entry 'z' in the Avro Record.

However, if the field is annotated such as case class Foo(@AvroName("x") z: String) then the entry in the Avro Record will be for 'x'.

Similarly for deserialization, if a field is annotated then the name that is looked up in the avro record will be the annotated name and not the field name in Scala.

The second example is with classes. If a class is annotated with @AvroName then the name used in the record schema will not be the classname but the annotated value.

This will also have an effect on serialization. For example, when decoding records into an Either, the decoder must decide if the value is a Left or a Right. It usually does this by comparing the name in the record to the classnames of the either types, but when annotated, it will compare the name in the record to the annotated value.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait StaticAnnotation
class Annotation
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Inherited methods

def getAllFields: Map[String, Any]

Attributes

Inherited from:
AvroFieldReflection
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product