Class Conversion<T>

java.lang.Object
org.apache.avro.Conversion<T>
Type Parameters:
T - a Java type that can represent the named logical type
Direct Known Subclasses:
Conversions.BigDecimalConversion, Conversions.DecimalConversion, Conversions.DurationConversion, Conversions.UUIDConversion, ProtoConversions.TimestampMicrosConversion, ProtoConversions.TimestampMillisConversion, ProtoConversions.TimestampNanosConversion, TimeConversions.DateConversion, TimeConversions.LocalTimestampMicrosConversion, TimeConversions.LocalTimestampMillisConversion, TimeConversions.LocalTimestampNanosConversion, TimeConversions.TimeMicrosConversion, TimeConversions.TimeMillisConversion, TimeConversions.TimestampMicrosConversion, TimeConversions.TimestampMillisConversion, TimeConversions.TimestampNanosConversion

public abstract class Conversion<T> extends Object
Conversion between generic and logical type instances.

Instances of this class can be added to GenericData to convert a logical type to a particular representation. This can be done manually, using GenericData.addLogicalTypeConversion(Conversion), or automatically. This last option uses the Java ServiceLoader, and requires the implementation to be a public class with a public no-arg constructor, be named in a file called /META-INF/services/org.apache.avro.Conversion, and both must available in the classpath.

Implementations must provide:

Subclasses must also override the conversion methods for Avro's base types that are valid for the logical type, or else risk causing UnsupportedOperationException at runtime.

Optionally, use getRecommendedSchema() to provide a Schema that will be used when generating a Schema for the class. This is useful when using ReflectData or ProtobufData, for example.

See Also: