public final class AvroUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends org.apache.avro.specific.SpecificRecord> |
binaryDecode(byte[] bytes,
Class<T> clazz)
Decode the specified byte array to its equivalent specific record.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
binaryEncode(T... instances)
Encode the specific record instances into a consecutive byte array
suitable for communication transfer.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
binaryEncode(T instance)
Encode the specific record instance into a byte array
suitable for communication transfer.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
decode(EtpEncoding encoding,
byte[] bytes,
Class<T> clazz)
Avro decode the specified byte stream.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
encode(EtpEncoding encoding,
T... instances)
Avro encode the specified set of instances.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
encode(EtpEncoding encoding,
T instance)
Avro encode the specified instance.
|
static String |
getDataType(Class<?> clazz)
Return the AVRO data type specifier for the specified java class.
|
static Class<?> |
getDataType(String avroType)
Return the java equivalent class of an Avro type.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
jsonDecode(byte[] bytes,
Class<T> clazz)
Decode the specified JSON byte array to its equivalent Avro specific record.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
jsonEncode(T... instances)
Encode the Avro specific record instances into a consecutive JSON byte array
suitable for communication transfer.
|
static <T extends org.apache.avro.specific.SpecificRecord> |
jsonEncode(T instance)
Encode the Avro specific record instance into a consecutive JSON byte array
suitable for communication transfer.
|
public static Class<?> getDataType(String avroType)
avroType
- Avro type to find Java equivalent class of.IllegalArgumentException
- If avroType is null.public static String getDataType(Class<?> clazz)
clazz
- Java class to get Avro type of.IllegalArgumentException
- If clazz is null.public static <T extends org.apache.avro.specific.SpecificRecord> byte[] binaryEncode(T instance)
instance
- Instance to decode. Non-null.@SafeVarargs public static <T extends org.apache.avro.specific.SpecificRecord> byte[] binaryEncode(T... instances)
instances
- Instances to decode. Non-null.public static <T extends org.apache.avro.specific.SpecificRecord> T binaryDecode(byte[] bytes, Class<T> clazz)
bytes
- Bytes to decode. Non-null.clazz
- Class of instance to return. Non-null.IllegalArgumentException
- If bytes or clazz is null.public static <T extends org.apache.avro.specific.SpecificRecord> byte[] jsonEncode(T instance)
instance
- Instance to decode. Non-null.IllegalArgumentException
- If instance is null.@SafeVarargs public static <T extends org.apache.avro.specific.SpecificRecord> byte[] jsonEncode(T... instances)
instances
- Instances to decode. Non-null.IllegalArgumentException
- If instances is null.public static <T extends org.apache.avro.specific.SpecificRecord> T jsonDecode(byte[] bytes, Class<T> clazz)
bytes
- Bytes to decode. Non-null.clazz
- Class of instance to return. Non-null.IllegalArgumentException
- If bytes or clazz is null.public static <T extends org.apache.avro.specific.SpecificRecord> byte[] encode(EtpEncoding encoding, T instance)
encoding
- Encoding to use. Non-null.instance
- Instance to encode. Non-null.IllegalArgumentException
- If encoding or instance is null.@SafeVarargs public static <T extends org.apache.avro.specific.SpecificRecord> byte[] encode(EtpEncoding encoding, T... instances)
encoding
- Encoding to use. Non-null.instances
- Instances to encode. Non-null.IllegalArgumentException
- If encoding or instances is null.public static <T extends org.apache.avro.specific.SpecificRecord> T decode(EtpEncoding encoding, byte[] bytes, Class<T> clazz)
encoding
- Encoding to use. Non-null.bytes
- Sequence of bytes to decode. Non-null.clazz
- Class of instance to create. Non-null.IllegalArgumentException
- If any of the arguments are null.Copyright © 2023 Petroware AS - https://petroware.no