Package com.hazelcast.nio.serialization
Interface GenericRecordBuilder
@Beta public interface GenericRecordBuilder
Interface for creating
GenericRecord
instances.-
Method Summary
Modifier and Type Method Description GenericRecord
build()
static GenericRecordBuilder
portable(ClassDefinition classDefinition)
Creates a Builder that will build aGenericRecord
inPortable
format with a new class definition:GenericRecordBuilder
setBoolean(String fieldName, boolean value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setBooleanArray(String fieldName, boolean[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setByte(String fieldName, byte value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setByteArray(String fieldName, byte[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setChar(String fieldName, char value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setCharArray(String fieldName, char[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setDate(String fieldName, LocalDate value)
Sets a date field consisting of year , month of the year and day of the month It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setDateArray(String fieldName, LocalDate[] value)
Sets an array of Date's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setDecimal(String fieldName, BigDecimal value)
Sets a decimal which is arbitrary precision and scale floating-point number It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setDecimalArray(String fieldName, BigDecimal[] value)
Sets an array of Decimals It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setDouble(String fieldName, double value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setDoubleArray(String fieldName, double[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setFloat(String fieldName, float value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setFloatArray(String fieldName, float[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setGenericRecord(String fieldName, GenericRecord value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setGenericRecordArray(String fieldName, GenericRecord[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setInt(String fieldName, int value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setIntArray(String fieldName, int[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setLong(String fieldName, long value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setLongArray(String fieldName, long[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setShort(String fieldName, short value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setShortArray(String fieldName, short[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setString(String fieldName, String value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setStringArray(String fieldName, String[] value)
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setTime(String fieldName, LocalTime value)
Sets a time field consisting of hour, minute, seconds and nanos parts It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setTimeArray(String fieldName, LocalTime[] value)
Sets an array of Time's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setTimestamp(String fieldName, LocalDateTime value)
Sets a timestamp field consisting of year , month of the year and day of the month, hour, minute, seconds, nanos parts It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setTimestampArray(String fieldName, LocalDateTime[] value)
Sets an array of Timestamp's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setTimestampWithTimezone(String fieldName, OffsetDateTime value)
Sets a timestamp with timezone field consisting of year , month of the year and day of the month, offset seconds , hour, minute, seconds, nanos parts It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.GenericRecordBuilder
setTimestampWithTimezoneArray(String fieldName, OffsetDateTime[] value)
Sets an array of TimestampWithTimezone's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
.
-
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) .addStringField("name").addIntField("id").build(); GenericRecord genericRecord = GenericRecord.Builder.portable(classDefinition) .setString("name", "foo") .setInt("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.
-
setBoolean
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setByte
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setChar
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setDouble
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setFloat
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setInt
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setLong
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setShort
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setString
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setGenericRecord
@Nonnull GenericRecordBuilder setGenericRecord(@Nonnull String fieldName, @Nullable GenericRecord value)It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setDecimal
Sets a decimal which is arbitrary precision and scale floating-point number It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setTime
Sets a time field consisting of hour, minute, seconds and nanos parts It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setDate
Sets a date field consisting of year , month of the year and day of the month It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setTimestamp
@Nonnull GenericRecordBuilder setTimestamp(@Nonnull String fieldName, @Nullable LocalDateTime value)Sets a timestamp field consisting of year , month of the year and day of the month, hour, minute, seconds, nanos parts It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setTimestampWithTimezone
@Nonnull GenericRecordBuilder setTimestampWithTimezone(@Nonnull String fieldName, @Nullable OffsetDateTime value)Sets a timestamp with timezone field consisting of year , month of the year and day of the month, offset seconds , hour, minute, seconds, nanos parts It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setBooleanArray
@Nonnull GenericRecordBuilder setBooleanArray(@Nonnull String fieldName, @Nullable boolean[] value)It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setByteArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setCharArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setFloatArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setIntArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setDoubleArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setLongArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setShortArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set to the same field twice.- Parameters:
fieldName
- name of the field as it is defined in its class definition. SeeClassDefinition
forPortable
value
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setStringArray
It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-
setDecimalArray
@Nonnull GenericRecordBuilder setDecimalArray(@Nonnull String fieldName, @Nullable BigDecimal[] value)Sets an array of Decimals It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.- See Also:
setDecimal(String, BigDecimal)
-
setTimeArray
Sets an array of Time's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.- See Also:
setTime(String, LocalTime)
-
setDateArray
Sets an array of Date's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.- See Also:
setDate(String, LocalDate)
-
setTimestampArray
@Nonnull GenericRecordBuilder setTimestampArray(@Nonnull String fieldName, @Nullable LocalDateTime[] value)Sets an array of Timestamp's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.- See Also:
setTimestamp(String, LocalDateTime)
-
setTimestampWithTimezoneArray
@Nonnull GenericRecordBuilder setTimestampWithTimezoneArray(@Nonnull String fieldName, @Nullable OffsetDateTime[] value)Sets an array of TimestampWithTimezone's It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.- See Also:
setTimestampWithTimezone(String, OffsetDateTime)
-
setGenericRecordArray
@Nonnull GenericRecordBuilder setGenericRecordArray(@Nonnull String fieldName, @Nullable GenericRecord[] value)It is legal to set the field again only when Builder is created withGenericRecord.cloneWithBuilder()
. Otherwise, it is illegal to set 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
- to set to GenericRecord- 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 set without usingGenericRecord.cloneWithBuilder()
.
-