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 SummaryConstructorsModifierConstructorDescriptionprotectedRecordBuilderBase(RecordBuilderBase<T> other, GenericData data) RecordBuilderBase copy constructor.protectedRecordBuilderBase(Schema schema, GenericData data) Creates a RecordBuilderBase for building records of the given type.
- 
Method SummaryModifier and TypeMethodDescriptionprotected final GenericDatadata()protected ObjectdefaultValue(Schema.Field field) Gets the default value of the given field, if any.booleanprotected final Schema.Field[]fields()protected final boolean[]inthashCode()protected static booleanisValidValue(Schema.Field f, Object value) Tests whether a value is valid for a specified field.protected final Schemaschema()protected voidvalidate(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.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.avro.data.RecordBuilderbuild
- 
Constructor Details- 
RecordBuilderBaseCreates a RecordBuilderBase for building records of the given type.- Parameters:
- schema- the schema associated with the record class.
 
- 
RecordBuilderBaseRecordBuilderBase copy constructor. Makes a deep copy of the values in the other builder.- Parameters:
- other- RecordBuilderBase instance to copy.
 
 
- 
- 
Method Details- 
schema
- 
fields
- 
fieldSetFlagsprotected final boolean[] fieldSetFlags()
- 
data
- 
validateValidates 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.
 
- 
isValidValueTests 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.
 
- 
defaultValueGets 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
 
- 
hashCodepublic int hashCode()
- 
equals
 
-