- All Implemented Interfaces:
Codec
- Enclosing class:
- Codecs
public static class Codecs.JsonCodec
extends Object
implements Codec
-
Constructor Summary
Constructors
-
Method Summary
boolean
Checks if the current codec can handle the serialization and deserialization of object from the given type.
Decodes the given bytes to an object.
byte[]
Encodes the given object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
JsonCodec
public JsonCodec(Type clazz)
-
Method Details
-
canHandle
public boolean canHandle(Type clazz)
Description copied from interface: Codec
Checks if the current codec can handle the serialization and deserialization of object from the given type.
- Specified by:
canHandle
in interface Codec
- Parameters:
clazz
- the type, cannot be null
- Returns:
true
if the codec can handle the type, false
otherwise
-
encode
public byte[] encode(Object item)
Description copied from interface: Codec
Encodes the given object.
The type of the given object matches the type used to call the
Codec.canHandle(Type)
method.
- Specified by:
encode
in interface Codec
- Parameters:
item
- the item
- Returns:
- the encoded content
-
decode
public Object decode(byte[] payload)
Description copied from interface: Codec
Decodes the given bytes to an object.
The codec must return an instance of the type used to call the
Codec.canHandle(Type)
method.
- Specified by:
decode
in interface Codec
- Parameters:
payload
- the bytes
- Returns:
- the object