Package io.activej.codec.registry
Class CodecRegistry
java.lang.Object
io.activej.codec.registry.CodecRegistry
- All Implemented Interfaces:
CodecFactory
public final class CodecRegistry extends Object implements CodecFactory
A registry which stores codecs by their type and allows dynamic dispatch of them.
Also it allows dynamic construction of codecs for generic types.
-
Method Summary
Modifier and Type Method Description static CodecRegistrycreate()Creates a new completely empty registry.static CodecRegistrycreateDefault()Creates a registry with a set of default codecs - primitives, some Java types, collections, ActiveJ tuples.<T> StructuredCodec<T>get(Type type)<T> CodecRegistrywith(Class<T> type, StructuredCodec<T> codec)<T> CodecRegistrywith(Class<T> type, Function<CodecFactory,StructuredCodec<T>> codec)<T> CodecRegistrywithGeneric(Class<T> type, BiFunction<CodecFactory,StructuredCodec<Object>[],StructuredCodec<? extends T>> fn)<T> CodecRegistrywithSubtypesOf(Class<T> type)<T> CodecRegistrywithSubtypesOf(Class<T> type, Function<Class<? extends T>,@Nullable String> subtypeNameFactory)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.activej.codec.registry.CodecFactory
get, get
-
Method Details
-
create
Creates a new completely empty registry. You are advised to usecreateDefault()factory method instead. -
createDefault
Creates a registry with a set of default codecs - primitives, some Java types, collections, ActiveJ tuples. -
with
-
with
-
withGeneric
public <T> CodecRegistry withGeneric(Class<T> type, BiFunction<CodecFactory,StructuredCodec<Object>[],StructuredCodec<? extends T>> fn) -
withSubtypesOf
-
withSubtypesOf
public <T> CodecRegistry withSubtypesOf(Class<T> type, Function<Class<? extends T>,@Nullable String> subtypeNameFactory) -
get
- Specified by:
getin interfaceCodecFactory
-