T
- a Java type that generic data is converted topublic abstract class Conversion<T> extends Object
Instances of this class are added to GenericData to convert a logical type to a particular representation.
Implementations must provide: * getConvertedType()
: get the Java
class used for the logical type * getLogicalTypeName()
: get the
logical type this implements
Subclasses must also override all of 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 a Schema is generated for the class returned by
getConvertedType
.
Constructor and Description |
---|
Conversion() |
public abstract Class<T> getConvertedType()
public abstract String getLogicalTypeName()
public String adjustAndSetValue(String varName, String valParamName)
varName
- valParamName
- public Schema getRecommendedSchema()
public T fromBoolean(Boolean value, Schema schema, LogicalType type)
public T fromInt(Integer value, Schema schema, LogicalType type)
public T fromLong(Long value, Schema schema, LogicalType type)
public T fromFloat(Float value, Schema schema, LogicalType type)
public T fromDouble(Double value, Schema schema, LogicalType type)
public T fromCharSequence(CharSequence value, Schema schema, LogicalType type)
public T fromEnumSymbol(GenericEnumSymbol value, Schema schema, LogicalType type)
public T fromFixed(GenericFixed value, Schema schema, LogicalType type)
public T fromBytes(ByteBuffer value, Schema schema, LogicalType type)
public T fromArray(Collection<?> value, Schema schema, LogicalType type)
public T fromMap(Map<?,?> value, Schema schema, LogicalType type)
public T fromRecord(IndexedRecord value, Schema schema, LogicalType type)
public Boolean toBoolean(T value, Schema schema, LogicalType type)
public Integer toInt(T value, Schema schema, LogicalType type)
public Long toLong(T value, Schema schema, LogicalType type)
public Float toFloat(T value, Schema schema, LogicalType type)
public Double toDouble(T value, Schema schema, LogicalType type)
public CharSequence toCharSequence(T value, Schema schema, LogicalType type)
public GenericEnumSymbol toEnumSymbol(T value, Schema schema, LogicalType type)
public GenericFixed toFixed(T value, Schema schema, LogicalType type)
public ByteBuffer toBytes(T value, Schema schema, LogicalType type)
public Collection<?> toArray(T value, Schema schema, LogicalType type)
public Map<?,?> toMap(T value, Schema schema, LogicalType type)
public IndexedRecord toRecord(T value, Schema schema, LogicalType type)
Copyright © 2009–2020 The Apache Software Foundation. All rights reserved.