public class NullableSerializer<T> extends Object implements Serializer<T>
null
value serialization.Modifier and Type | Method and Description |
---|---|
static <T> boolean |
checkIfNullSupported(Serializer<T> serializer)
This method checks if
serializer supports null value. |
T |
copy(T from)
Creates a deep copy of the given element in a new element.
|
T |
deserialize(DataInputView source)
De-serializes a record from the given source input view.
|
Serializer<T> |
duplicate()
Creates a deep copy of this serializer if it is necessary, i.e.
|
boolean |
equals(Object obj) |
int |
hashCode() |
void |
serialize(T record,
DataOutputView target)
Serializes the given record to the given target output view.
|
static <T> Serializer<T> |
wrap(Serializer<T> originalSerializer)
This method wraps the
originalSerializer with the NullableSerializer if not
already wrapped. |
static <T> Serializer<T> |
wrapIfNullIsNotSupported(Serializer<T> originalSerializer)
This method tries to serialize
null value with the originalSerializer and
wraps it in case of NullPointerException , otherwise it returns the originalSerializer . |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
deserializeFromString, serializeToString
public static <T> Serializer<T> wrapIfNullIsNotSupported(@Nonnull Serializer<T> originalSerializer)
null
value with the originalSerializer
and
wraps it in case of NullPointerException
, otherwise it returns the originalSerializer
.originalSerializer
- serializer to wrap and add null
supportnull
valuespublic static <T> boolean checkIfNullSupported(Serializer<T> serializer)
serializer
supports null
value.serializer
- serializer to checkpublic static <T> Serializer<T> wrap(Serializer<T> originalSerializer)
originalSerializer
with the NullableSerializer
if not
already wrapped.originalSerializer
- serializer to wrap and add null
supportnull
valuespublic Serializer<T> duplicate()
Serializer
We need this because Serializers might be used in several threads. Stateless serializers are inherently thread-safe while stateful serializers might not be thread-safe.
duplicate
in interface Serializer<T>
public T copy(T from)
Serializer
copy
in interface Serializer<T>
from
- The element reuse be copied.public void serialize(T record, DataOutputView target) throws IOException
Serializer
serialize
in interface Serializer<T>
record
- The record to serialize.target
- The output view to write the serialized data to.IOException
- Thrown, if the serialization encountered an I/O related error. Typically
raised by the output view, which may have an underlying I/O channel to which it
delegates.public T deserialize(DataInputView source) throws IOException
Serializer
deserialize
in interface Serializer<T>
source
- The input view from which to read the data.IOException
- Thrown, if the de-serialization encountered an I/O related error.
Typically raised by the input view, which may have an underlying I/O channel from which
it reads.Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.