Class Conversions

java.lang.Object
org.apache.avro.Conversions

public class Conversions extends Object
  • Constructor Details

    • Conversions

      public Conversions()
  • Method Details

    • convertToLogicalType

      public static Object convertToLogicalType(Object datum, Schema schema, LogicalType type, Conversion<?> conversion)
      Convert an underlying representation of a logical type (such as a ByteBuffer) to a higher level object (such as a BigDecimal).
      Parameters:
      datum - The object to be converted.
      schema - The schema of datum. Cannot be null if datum is not null.
      type - The LogicalType of datum. Cannot be null if datum is not null.
      conversion - The tool used to finish the conversion. Cannot be null if datum is not null.
      Returns:
      The result object, which is a high level object of the logical type. The null datum always converts to a null value.
      Throws:
      IllegalArgumentException - if datum is not null, but schema, type or conversion is.
    • convertToRawType

      public static <T> Object convertToRawType(Object datum, Schema schema, LogicalType type, Conversion<T> conversion)
      Convert a high level representation of a logical type (such as a BigDecimal) to its underlying representation object (such as a ByteBuffer)
      Parameters:
      datum - The object to be converted.
      schema - The schema of datum. Cannot be null if datum is not null.
      type - The LogicalType of datum. Cannot be null if datum is not null.
      conversion - The tool used to finish the conversion. Cannot be null if datum is not null.
      Returns:
      The result object, which is an underlying representation object of the logical type. If the input param datum is null, a null value will be returned.
      Throws:
      IllegalArgumentException - if datum is not null, but schema, type or conversion is.