Package io.activej.codec
Class CodecSubtype<T>
java.lang.Object
io.activej.codec.CodecSubtype<T>
- All Implemented Interfaces:
StructuredCodec<T>,StructuredDecoder<T>,StructuredEncoder<T>,WithInitializer<CodecSubtype<T>>
public final class CodecSubtype<T> extends Object implements WithInitializer<CodecSubtype<T>>, StructuredCodec<T>
This is a
codec that stores subtypes of T with different codecs
as a tagged union with string tags.-
Method Summary
Modifier and Type Method Description static <T> CodecSubtype<T>create()Tdecode(StructuredInput in)voidencode(StructuredOutput out, T value)CodecSubtype<T>with(Type type, StructuredCodec<? extends T> adapter)Add a subtype along with its codec and string tag which is extracted from the class nameCodecSubtype<T>with(Type type, String name, StructuredCodec<? extends T> adapter)Add a subtype along with its codec and custom string tagCodecSubtype<T>withTagName(String tagName)CodecSubtype<T>withTagName(String tagName, String dataName)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.activej.codec.StructuredCodec
nullable, ofList, transformMethods inherited from interface io.activej.common.api.WithInitializer
withInitializer
-
Method Details
-
create
-
withTagName
-
withTagName
-
with
Add a subtype along with its codec and custom string tag -
with
Add a subtype along with its codec and string tag which is extracted from the class name -
encode
- Specified by:
encodein interfaceStructuredEncoder<T>
-
decode
- Specified by:
decodein interfaceStructuredDecoder<T>- Throws:
MalformedDataException
-