Java types are mapped to Avro schemas as follows:
Nullable or a Union containing java.lang.Void .Union annotation, the "java-element"
property is set to the union's class, e.g.:
{"type": "array", "java-element": "org.acme.Foo"}
{"type": "array", "java-class": "java.util.ArrayList"}
java.lang.String is mapped to an Avro string schema.{"type": "int", "java-class": "java.lang.Short"}
java.math.BigDecimal , java.math.BigInteger ,
java.net.URI , java.net.URL , java.io.File
are mapped to an Avro string schema as
Stringable types and
serialized via their toString
method and de-serialized via their java.lang.String constructor.
This is done via the "java-class", "java-key-class" or
"java-element-class" depending on whether it is a field, or map key
or a list/map element, e.g.:
{"type": "string", "java-class": "java.math.BigDecimal"}generic API.The Union annotation can be used
to support reflection of schemas for interfaces, abstract base classes
and other uses of polymorphism.
The Stringable annotation
will cause a type to be serialized via its toString method.
Fields annotated with AvroIgnore
will not be written or read to.
The AvroName annotation renames
the field in the schema to the given name. The reflect datum reader will look
for a schema field with the given name, when trying to read into such an
annotated java field.
The AvroMeta annotation adds an
arbitrary key:value pair in the schema at the node of the java field.
The AvroSchema annotation forces
the use of an custom schema.
The AvroEncode annotation forces
the use of an custom encoder. This annotation overrides
Stringable and
Nullable.
| Modifier and Type | Annotation and Description |
|---|---|
| public @interface | AvroAlias
Adds the given name and space as an alias to the schema. |
| public @interface | |
| public @interface | AvroDefault
Specifies a default value for a field as a JSON string. |
| public @interface | AvroDoc
Sets the avrodoc for this java field. |
| public @interface | AvroEncode
Expert: Fields with this annotation are encoded using the given custom encoder. |
| public @interface | AvroIgnore
Marks a field as transient. |
| public @interface | AvroMeta
Adds the given key:Value pair as metadata into the schema, at the corresponding node. |
| public @interface | AvroName
Sets the avroname for this java field. |
| public @interface | AvroSchema
Declares that a Java type should have a specified Avro schema, overriding the normally inferred schema. |
| public @interface | Nullable
Declares that null is a valid value for a Java type. |
| public @interface | Stringable
Declares that a class or field should be represented by an Avro string. |
| public @interface | Union
Declares that a Java type should be represented by an Avro union schema. |
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | ArrayAccessor
Helper class to provide native array access whenever possible. |
| public abstract class | CustomEncoding<
The class of objects that can be serialized with this encoder /
decoder. T>Expert: a custom encoder and decoder that writes an object directly to avro. |
| public class | DateAsLongEncoding
This encoder/decoder writes a java.util.Date object as a long to avro and reads a Date object from long. |
| pack-priv abstract class | |
| pack-priv abstract class | |
| pack-priv class | |
| pack-priv class | |
| public class | MapEntry<
Key of the map-entry K, Value of the map-entry V>
Deprecated
Use org.apache.avro.util.MapEntry
Class to make Avro immune from the naming variations of key/value fields
among several java. implementations.
|
| public class | ReflectData
Utilities to use existing Java classes and interfaces via reflection. |
| public class | |
| public class | |
| public class | ReflectionUtil
A few utility methods for using @link{java.misc.Unsafe}, mostly for private use. |