Interface Serializer<T>
- Type Parameters:
T- the target type of this serializer.
- All Known Implementing Classes:
MappedSerializer
public interface Serializer<T>
Writes/reads an object to/from a binary stream.
- Author:
- Paul Ferraro
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Serializer<T> of(T value) Reads an object from the specified input stream.default OptionalIntReturns the size of the buffer to use for marshalling the specified object, if known.voidwrite(DataOutput output, T value) Writes the specified object to the specified output stream
-
Method Details
-
write
Writes the specified object to the specified output stream- Parameters:
output- the data output streamvalue- an object to serialize- Throws:
IOException- if an I/O error occurs
-
read
Reads an object from the specified input stream.- Parameters:
input- a data input stream- Returns:
- the deserialized object
- Throws:
IOException- if an I/O error occurs
-
size
Returns the size of the buffer to use for marshalling the specified object, if known.- Parameters:
object- the object to be sized- Returns:
- the buffer size (in bytes), or empty if unknown.
-
of
-