Class InetSocketAddressSerializer
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.serializers.InetSocketAddressSerializer
- All Implemented Interfaces:
BabelNetworkSerializer<InetSocketAddress>
public class InetSocketAddressSerializer
extends Object
implements BabelNetworkSerializer<InetSocketAddress>
Serializer for
InetSocketAddress instances, supporting both IPv4 (4 bytes)
and IPv6 (16 bytes) addresses along with a 4-byte port number.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(io.netty.buffer.ByteBuf buffer, NodeStore store) Reads anInetSocketAddressfrom the buffer.intgetEstimateSize(InetSocketAddress object) Returns an estimated size in bytes for the given object.ReturnsBabelNode.class, which is the type key used bySerializerRegistryto locate this serializer when encoding or decodingBabelNodefields in generated message serializers.voidserialize(InetSocketAddress object, io.netty.buffer.ByteBuf out, NodeStore store) Encodesobjectand 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(InetSocketAddress object, @Nullable NodeStore store) Returns a size estimate to fit the entire object in aByteBufwithout needing resizes.
-
Constructor Details
-
InetSocketAddressSerializer
public InetSocketAddressSerializer()Constructs a newInetSocketAddressSerializer.
-
-
Method Details
-
deserialize
Reads anInetSocketAddressfrom the buffer.- Specified by:
deserializein interfaceBabelNetworkSerializer<InetSocketAddress>- Parameters:
buffer- the source buffer positioned at the address-family discriminant bytestore- the node store context- Returns:
- the decoded
InetSocketAddress - Throws:
IllegalArgumentException- if the address bytes cannot be resolved to anInetAddress
-
serialize
Description copied from interface:BabelNetworkSerializerEncodesobjectand appends the resulting bytes toout.- Specified by:
serializein interfaceBabelNetworkSerializer<InetSocketAddress>- Parameters:
object- the object to serializeout- the destination bufferstore- the node store context for resolving node components
-
getObjectClass
ReturnsBabelNode.class, which is the type key used bySerializerRegistryto locate this serializer when encoding or decodingBabelNodefields in generated message serializers.- Specified by:
getObjectClassin interfaceBabelNetworkSerializer<InetSocketAddress>- Returns:
BabelNode.class
-
getEstimateSize
Description copied from interface:BabelNetworkSerializerReturns an estimated size in bytes for the given object.- Specified by:
getEstimateSizein interfaceBabelNetworkSerializer<InetSocketAddress>- Parameters:
object- the object to estimate- Returns:
- estimated byte size, or 0 if unknown
-