Class Codecs
java.lang.Object
com.iantapply.relay.api.Codecs
Factory methods for the codecs supplied with Relay.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MessageCodec<byte[]> bytes()Returns a codec that defensively copies binary payloads.static <T> MessageCodec<T> Returns a Gson-backed JSON codec for a concrete value type.static MessageCodec<String> utf8()Returns a codec for UTF-8 text.
-
Method Details
-
utf8
Returns a codec for UTF-8 text.- Returns:
- a UTF-8 string codec
-
bytes
Returns a codec that defensively copies binary payloads.- Returns:
- a binary codec
-
json
Returns a Gson-backed JSON codec for a concrete value type.- Type Parameters:
T- encoded value type- Parameters:
type- type to deserialize- Returns:
- a JSON codec for
type - Throws:
NullPointerException- iftypeisnull
-