Package org.apache.avro.data
Class RecordBuilderBase<T extends IndexedRecord>
java.lang.Object
org.apache.avro.data.RecordBuilderBase<T>
- All Implemented Interfaces:
RecordBuilder<T>
- Direct Known Subclasses:
GenericRecordBuilder
,SpecificErrorBuilderBase
,SpecificRecordBuilderBase
public abstract class RecordBuilderBase<T extends IndexedRecord>
extends Object
implements RecordBuilder<T>
Abstract base class for RecordBuilder implementations. Not thread-safe.
-
Constructor Summary
ModifierConstructorDescriptionprotected
RecordBuilderBase
(RecordBuilderBase<T> other, GenericData data) RecordBuilderBase copy constructor.protected
RecordBuilderBase
(Schema schema, GenericData data) Creates a RecordBuilderBase for building records of the given type. -
Method Summary
Modifier and TypeMethodDescriptionprotected final GenericData
data()
protected Object
defaultValue
(Schema.Field field) Gets the default value of the given field, if any.boolean
protected final Schema.Field[]
fields()
protected final boolean[]
int
hashCode()
protected static boolean
isValidValue
(Schema.Field f, Object value) Tests whether a value is valid for a specified field.protected final Schema
schema()
protected void
validate
(Schema.Field field, Object value) Validates that a particular value for a given field is valid according to the following algorithm: 1.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.avro.data.RecordBuilder
build
-
Constructor Details
-
RecordBuilderBase
Creates a RecordBuilderBase for building records of the given type.- Parameters:
schema
- the schema associated with the record class.
-
RecordBuilderBase
RecordBuilderBase copy constructor. Makes a deep copy of the values in the other builder.- Parameters:
other
- RecordBuilderBase instance to copy.
-
-
Method Details
-
schema
-
fields
-
fieldSetFlags
protected final boolean[] fieldSetFlags() -
data
-
validate
Validates that a particular value for a given field is valid according to the following algorithm: 1. If the value is not null, or the field type is null, or the field type is a union which accepts nulls, returns. 2. Else, if the field has a default value, returns. 3. Otherwise throws AvroRuntimeException.- Parameters:
field
- the field to validate.value
- the value to validate.- Throws:
AvroRuntimeException
- if value is null and the given field does not accept null values.
-
isValidValue
Tests whether a value is valid for a specified field.- Parameters:
f
- the field for which to test the value.value
- the value to test.- Returns:
- true if the value is valid for the given field; false otherwise.
-
defaultValue
Gets the default value of the given field, if any.- Parameters:
field
- the field whose default value should be retrieved.- Returns:
- the default value associated with the given field, or null if none is specified in the schema.
- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-