Package com.hazelcast.nio.serialization
Interface GenericRecord.Builder
- Enclosing interface:
- GenericRecord
@Beta public static interface GenericRecord.Builder
Interface for creating
GenericRecord
instances.-
Method Summary
Modifier and Type Method Description GenericRecord
build()
static GenericRecord.Builder
portable(ClassDefinition classDefinition)
Creates a Builder that will build aGenericRecord
inPortable
format with a new class definition:GenericRecord.Builder
writeBoolean(String fieldName, boolean value)
It is legal to overwrite the field once only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecord.Builder
writeBooleanArray(String fieldName, boolean[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeByte(String fieldName, byte value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeByteArray(String fieldName, byte[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeChar(String fieldName, char value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeCharArray(String fieldName, char[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeDouble(String fieldName, double value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeDoubleArray(String fieldName, double[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeFloat(String fieldName, float value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeFloatArray(String fieldName, float[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeGenericRecord(String fieldName, GenericRecord value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeGenericRecordArray(String fieldName, GenericRecord[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeInt(String fieldName, int value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeIntArray(String fieldName, int[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeLong(String fieldName, long value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeLongArray(String fieldName, long[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeShort(String fieldName, short value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeShortArray(String fieldName, short[] value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeUTF(String fieldName, String value)
It is illegal to write to the same field twice.GenericRecord.Builder
writeUTFArray(String fieldName, String[] value)
It is illegal to write to the same field twice.
-
Method Details
-
portable
Creates a Builder that will build aGenericRecord
inPortable
format with a new class definition:ClassDefinition classDefinition = new ClassDefinitionBuilder(FACTORY_ID, CLASS_ID) .addUTFField("name").addIntField("id").build(); GenericRecord genericRecord = GenericRecord.Builder.portable(classDefinition) .writeUTF("name", "foo") .writeInt("id", 123).build();
- Parameters:
classDefinition
- of the portable that we will create- Returns:
- GenericRecordBuilder for Portable format
-
build
- Returns:
- a new constructed GenericRecord
- Throws:
HazelcastSerializationException
- when the GenericRecord cannot be build.
-
writeBoolean
It is legal to overwrite the field once only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. It should be composed of only alpha-numeric characters. SeeClassDefinition
forPortable
value
-- Returns:
- itself for chaining
- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeByte
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. It should be composed of only alpha-numeric characters. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeChar
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeDouble
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeFloat
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeInt
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeLong
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeShort
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeUTF
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeGenericRecord
It is illegal to write to the same field twice. This method allows nested structures. Subclass should also created as `GenericRecord`- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeBooleanArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeByteArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeCharArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeFloatArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeIntArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeDoubleArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeLongArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeShortArray
It is illegal to write to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeUTFArray
It is illegal to write to the same field twice.Array items can not be null
- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-
writeGenericRecordArray
GenericRecord.Builder writeGenericRecordArray(@Nonnull String fieldName, @Nullable GenericRecord[] value)It is illegal to write to the same field twice. This method allows nested structures. Subclasses should also created as `GenericRecord`Array items can not be null
- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
-- Throws:
HazelcastSerializationException
- if the field name does not exist in the class definition or the type of the field does not match the one in the class definition or Same field is trying to be overwritten without usingGenericRecord.cloneWithBuilder()
.
-