Class SortedSetSerializer<T extends Comparable<?>>
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.serializers.collections.SortedSetSerializer<T>
- Type Parameters:
T- the type of comparable elements in the set
- All Implemented Interfaces:
BabelNetworkSerializer<SortedSet<T>>
public class SortedSetSerializer<T extends Comparable<?>>
extends Object
implements BabelNetworkSerializer<SortedSet<T>>
Network serializer for Java
SortedSet collections.
Sorted sets are serialized by writing an integer size followed by each serialized element.
Upon deserialization, an ImmutableSortedSet with natural ordering is constructed.
-
Constructor Summary
ConstructorsConstructorDescriptionSortedSetSerializer(BabelNetworkSerializer<T> serializer) Constructs a new sorted set serializer using the given element serializer. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(io.netty.buffer.ByteBuf in, NodeStore store) Reads an instance ofTfrom the supplied buffer.intgetEstimateSize(SortedSet<T> object) Returns an estimated size in bytes for the given object.Returns the class of objects handled by this serializer, used for registry lookup.voidEncodesobjectand appends the resulting bytes toout.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelNetworkSerializer
getEstimateSizeModifier and TypeMethodDescriptiondefault intgetEstimateSize(SortedSet<T> object, @Nullable NodeStore store) Returns a size estimate to fit the entire object in aByteBufwithout needing resizes.
-
Constructor Details
-
SortedSetSerializer
Constructs a new sorted set serializer using the given element serializer.- Parameters:
serializer- the serializer for set elements
-
-
Method Details
-
serialize
Description copied from interface:BabelNetworkSerializerEncodesobjectand appends the resulting bytes toout.- Specified by:
serializein interfaceBabelNetworkSerializer<T extends Comparable<?>>- Parameters:
object- the object to serializeout- the destination bufferstore- the node store context for resolving node components
-
deserialize
Description copied from interface:BabelNetworkSerializerReads an instance ofTfrom the supplied buffer. The buffer's reader index must be positioned at the first byte of the encoded object. Upon return the reader index is advanced past all bytes consumed.- Specified by:
deserializein interfaceBabelNetworkSerializer<T extends Comparable<?>>- Parameters:
in- the source bufferstore- the node store context for resolving node components- Returns:
- the deserialized object
-
getObjectClass
Description copied from interface:BabelNetworkSerializerReturns the class of objects handled by this serializer, used for registry lookup.- Specified by:
getObjectClassin interfaceBabelNetworkSerializer<T extends Comparable<?>>- Returns:
- the handled class
-
getEstimateSize
Description copied from interface:BabelNetworkSerializerReturns an estimated size in bytes for the given object.- Specified by:
getEstimateSizein interfaceBabelNetworkSerializer<T extends Comparable<?>>- Parameters:
object- the object to estimate- Returns:
- estimated byte size, or 0 if unknown
-