Package com.github.f4b6a3.uuid.codec
Class BinaryCodec
- java.lang.Object
-
- com.github.f4b6a3.uuid.codec.BinaryCodec
-
- All Implemented Interfaces:
UuidCodec<byte[]>
public class BinaryCodec extends Object implements UuidCodec<byte[]>
Codec for UUID binary encoding as defined in the RFC-4122. The UUID is encoded as 16 octets (bytes). Read: https://tools.ietf.org/html/rfc4122 Read also: https://en.wikipedia.org/wiki/Universally_unique_identifier#Encoding
-
-
Field Summary
Fields Modifier and Type Field Description static BinaryCodecINSTANCEA shared immutable instance.
-
Constructor Summary
Constructors Constructor Description BinaryCodec()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UUIDdecode(byte[] bytes)Get a UUID from an array of bytes.byte[]encode(UUID uuid)Get an array of bytes from a UUID.
-
-
-
Field Detail
-
INSTANCE
public static final BinaryCodec INSTANCE
A shared immutable instance.
-
-
Method Detail
-
encode
public byte[] encode(UUID uuid)
Get an array of bytes from a UUID.
-
decode
public UUID decode(byte[] bytes)
Get a UUID from an array of bytes.- Specified by:
decodein interfaceUuidCodec<byte[]>- Parameters:
bytes- an array of bytes- Returns:
- a UUID
- Throws:
InvalidUuidException- if invalid
-
-