public interface CompactReader
Read operations might throw HazelcastSerializationException
when a
field with the given name is not found or there is a type mismatch.
The way to use CompactReader
for class evolution is to check for the
existence of a field with its name and kind, with the
getFieldKind(String)
method. One should read the field if it exists
with the given name and kind, and use some other logic, like using a default
value, if it does not exist.
public Foo read(CompactReader reader) {
int bar = reader.readInt32("bar"); // A field that is always present
String baz;
if (reader.getFieldKind("baz") == FieldKind.STRING) {
baz = reader.readString("baz");
} else {
baz = ""; // Use a default value, if the field is not present
}
return new Foo(bar, baz);
}
Modifier and Type | Method and Description |
---|---|
FieldKind |
getFieldKind(String fieldName)
Returns the kind of the field for the given field name.
|
boolean[] |
readArrayOfBoolean(String fieldName)
Reads an array of booleans.
|
<T> T[] |
readArrayOfCompact(String fieldName,
Class<T> componentType)
Reads an array of compact objects.
|
LocalDate[] |
readArrayOfDate(String fieldName)
Reads an array of dates consisting of year, month, and day.
|
BigDecimal[] |
readArrayOfDecimal(String fieldName)
Reads an array of arbitrary precision and scale floating point numbers.
|
float[] |
readArrayOfFloat32(String fieldName)
Reads an array of 32-bit IEEE 754 floating point numbers.
|
double[] |
readArrayOfFloat64(String fieldName)
Reads an array of 64-bit IEEE 754 floating point numbers.
|
short[] |
readArrayOfInt16(String fieldName)
Reads an array of 16-bit two's complement signed integers.
|
int[] |
readArrayOfInt32(String fieldName)
Reads an array of 32-bit two's complement signed integers.
|
long[] |
readArrayOfInt64(String fieldName)
Reads an array of 64-bit two's complement signed integers.
|
byte[] |
readArrayOfInt8(String fieldName)
Reads an array of 8-bit two's complement signed integers.
|
Boolean[] |
readArrayOfNullableBoolean(String fieldName)
Reads a nullable array of nullable booleans.
|
Float[] |
readArrayOfNullableFloat32(String fieldName)
Reads a nullable array of nullable 32-bit IEEE 754 floating point
numbers.
|
Double[] |
readArrayOfNullableFloat64(String fieldName)
Reads a nullable array of nullable 64-bit IEEE 754 floating point
numbers.
|
Short[] |
readArrayOfNullableInt16(String fieldName)
Reads a nullable array of nullable 16-bit two's complement signed
integers.
|
Integer[] |
readArrayOfNullableInt32(String fieldName)
Reads a nullable array of nullable 32-bit two's complement signed
integers.
|
Long[] |
readArrayOfNullableInt64(String fieldName)
Reads a nullable array of nullable 64-bit two's complement signed
integers.
|
Byte[] |
readArrayOfNullableInt8(String fieldName)
Reads a nullable array of nullable 8-bit two's complement signed
integers.
|
String[] |
readArrayOfString(String fieldName)
Reads an array of UTF-8 encoded strings.
|
LocalTime[] |
readArrayOfTime(String fieldName)
Reads an array of times consisting of hour, minute, second, and
nanoseconds
|
LocalDateTime[] |
readArrayOfTimestamp(String fieldName)
Reads an array of timestamps consisting of date and time.
|
OffsetDateTime[] |
readArrayOfTimestampWithTimezone(String fieldName)
Reads an array of timestamps with timezone consisting of date, time and
timezone offset.
|
boolean |
readBoolean(String fieldName)
Reads a boolean.
|
<T> T |
readCompact(String fieldName)
Reads a compact object
|
LocalDate |
readDate(String fieldName)
Reads a date consisting of year, month, and day.
|
BigDecimal |
readDecimal(String fieldName)
Reads an arbitrary precision and scale floating point number.
|
float |
readFloat32(String fieldName)
Reads a 32-bit IEEE 754 floating point number.
|
double |
readFloat64(String fieldName)
Reads a 64-bit IEEE 754 floating point number.
|
short |
readInt16(String fieldName)
Reads a 16-bit two's complement signed integer.
|
int |
readInt32(String fieldName)
Reads a 32-bit two's complement signed integer.
|
long |
readInt64(String fieldName)
Reads a 64-bit two's complement signed integer.
|
byte |
readInt8(String fieldName)
Reads an 8-bit two's complement signed integer.
|
Boolean |
readNullableBoolean(String fieldName)
Reads a nullable boolean.
|
Float |
readNullableFloat32(String fieldName)
Reads a nullable 32-bit IEEE 754 floating point number.
|
Double |
readNullableFloat64(String fieldName)
Reads a nullable 64-bit IEEE 754 floating point number.
|
Short |
readNullableInt16(String fieldName)
Reads a nullable 16-bit two's complement signed integer.
|
Integer |
readNullableInt32(String fieldName)
Reads a nullable 32-bit two's complement signed integer.
|
Long |
readNullableInt64(String fieldName)
Reads a nullable 64-bit two's complement signed integer.
|
Byte |
readNullableInt8(String fieldName)
Reads a nullable 8-bit two's complement signed integer.
|
String |
readString(String fieldName)
Reads an UTF-8 encoded string.
|
LocalTime |
readTime(String fieldName)
Reads a time consisting of hour, minute, second, and nano seconds.
|
LocalDateTime |
readTimestamp(String fieldName)
Reads a timestamp consisting of date and time.
|
OffsetDateTime |
readTimestampWithTimezone(String fieldName)
Reads a timestamp with timezone consisting of date, time and timezone
offset.
|
@Nonnull FieldKind getFieldKind(@Nonnull String fieldName)
If the field with the given name does not exist,
FieldKind.NOT_AVAILABLE
is returned.
This method can be used to check the existence of a field, which can be useful when the class is evolved.
fieldName
- name of the field.boolean readBoolean(@Nonnull String fieldName)
This method can also read a nullable boolean, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.byte readInt8(@Nonnull String fieldName)
This method can also read a nullable int8, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.short readInt16(@Nonnull String fieldName)
This method can also read a nullable int16, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.int readInt32(@Nonnull String fieldName)
This method can also read a nullable int32, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.long readInt64(@Nonnull String fieldName)
This method can also read a nullable int64, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.float readFloat32(@Nonnull String fieldName)
This method can also read a nullable float32, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.double readFloat64(@Nonnull String fieldName)
This method can also read a nullable float64, as long as it is not
null
. If a null
value is read with this method,
HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable String readString(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable BigDecimal readDecimal(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable LocalTime readTime(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable LocalDate readDate(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable LocalDateTime readTimestamp(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable OffsetDateTime readTimestampWithTimezone(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable <T> T readCompact(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist
in the schema or the type
of the field does not match
with the one defined in the
schema.HazelcastException
- if the object cannot be
created.@Nullable boolean[] readArrayOfBoolean(@Nonnull String fieldName)
This method can also read an array of nullable booleans, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable byte[] readArrayOfInt8(@Nonnull String fieldName)
This method can also read an array of nullable int8s, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable short[] readArrayOfInt16(@Nonnull String fieldName)
This method can also read an array of nullable int16s, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable int[] readArrayOfInt32(@Nonnull String fieldName)
This method can also read an array of nullable int32s, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable long[] readArrayOfInt64(@Nonnull String fieldName)
This method can also read an array of nullable int64s, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable float[] readArrayOfFloat32(@Nonnull String fieldName)
This method can also read an array of nullable float32s, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable double[] readArrayOfFloat64(@Nonnull String fieldName)
This method can also read an array of nullable float64s, as long as it
does not contain null
values. If a null
array item is
read with this method, HazelcastSerializationException
is thrown.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable String[] readArrayOfString(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable BigDecimal[] readArrayOfDecimal(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable LocalTime[] readArrayOfTime(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable LocalDate[] readArrayOfDate(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable LocalDateTime[] readArrayOfTimestamp(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable OffsetDateTime[] readArrayOfTimestampWithTimezone(@Nonnull String fieldName)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable <T> T[] readArrayOfCompact(@Nonnull String fieldName, @Nullable Class<T> componentType)
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Boolean readNullableBoolean(@Nonnull String fieldName)
This method can also read a non-nullable boolean.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Byte readNullableInt8(@Nonnull String fieldName)
This method can also read a non-nullable int8.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Short readNullableInt16(@Nonnull String fieldName)
This method can also read a non-nullable int16.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Integer readNullableInt32(@Nonnull String fieldName)
This method can also read a non-nullable int32.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Long readNullableInt64(@Nonnull String fieldName)
This method can also read a non-nullable int64.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Float readNullableFloat32(@Nonnull String fieldName)
This method can also read a non-nullable float32.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Double readNullableFloat64(@Nonnull String fieldName)
This method can also read a non-nullable float64.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Boolean[] readArrayOfNullableBoolean(@Nonnull String fieldName)
This method can also read array of non-nullable booleans.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Byte[] readArrayOfNullableInt8(@Nonnull String fieldName)
This method can also read array of non-nullable int8s.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Short[] readArrayOfNullableInt16(@Nonnull String fieldName)
This method can also read array of non-nullable int16s.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Integer[] readArrayOfNullableInt32(@Nonnull String fieldName)
This method can also read array of non-nullable int32s.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Long[] readArrayOfNullableInt64(@Nonnull String fieldName)
This method can also read array of non-nullable int64s.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Float[] readArrayOfNullableFloat32(@Nonnull String fieldName)
This method can also read array of non-nullable float32s.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.@Nullable Double[] readArrayOfNullableFloat64(@Nonnull String fieldName)
This method can also read array of non-nullable float64s.
fieldName
- name of the field.HazelcastSerializationException
- if the field does not exist in
the schema or the type of the
field does not match with the one
defined in the schema.Copyright © 2024 Hazelcast, Inc.. All rights reserved.