Package io.activej.codec
Class StructuredCodecs
java.lang.Object
io.activej.codec.StructuredCodecs
public final class StructuredCodecs extends Object
This class contains various primitive
StructuredCodecs and their combinators.-
Field Summary
Fields Modifier and Type Field Description static StructuredCodec<Boolean>BOOLEAN_CODECstatic StructuredCodec<Byte>BYTE_CODECstatic StructuredCodec<byte[]>BYTES_CODECstatic StructuredCodec<Character>CHARACTER_CODECstatic StructuredCodec<Class<?>>CLASS_CODECstatic StructuredCodec<Double>DOUBLE_CODECstatic StructuredCodec<Float>FLOAT_CODECstatic StructuredCodec<Integer>INT_CODECstatic StructuredCodec<Integer>INT32_CODECstatic StructuredCodec<Long>LONG_CODECstatic StructuredCodec<Long>LONG64_CODECstatic StructuredCodec<Short>SHORT_CODECstatic StructuredCodec<String>STRING_CODECstatic StructuredCodec<Void>VOID_CODEC -
Constructor Summary
Constructors Constructor Description StructuredCodecs() -
Method Summary
Modifier and Type Method Description static <T> StructuredCodec<List<T>>concat(StructuredCodec<? extends T>... elementCodecs)static <T> StructuredCodec<List<T>>concat(List<StructuredCodec<? extends T>> elementCodecs)Combinator codec that writes/reads a heterogeneous list using codecs from given list without list boundariesstatic <R> StructuredCodec<R>object(TupleDecoder0<R> constructor)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <R, T1> StructuredCodec<R>object(TupleDecoder1<T1,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <R, T1, T2> StructuredCodec<R>object(TupleDecoder2<T1,T2,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <R, T1, T2, T3>
StructuredCodec<R>object(TupleDecoder3<T1,T2,T3,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <R, T1, T2, T3, T4>
StructuredCodec<R>object(TupleDecoder4<T1,T2,T3,T4,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3, String field4, Function<R,T4> getter4, StructuredCodec<T4> codec4)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <R, T1, T2, T3, T4, T5>
StructuredCodec<R>object(TupleDecoder5<T1,T2,T3,T4,T5,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3, String field4, Function<R,T4> getter4, StructuredCodec<T4> codec4, String field5, Function<R,T5> getter5, StructuredCodec<T5> codec5)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <R, T1, T2, T3, T4, T5, T6>
StructuredCodec<R>object(TupleDecoder6<T1,T2,T3,T4,T5,T6,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3, String field4, Function<R,T4> getter4, StructuredCodec<T4> codec4, String field5, Function<R,T5> getter5, StructuredCodec<T5> codec5, String field6, Function<R,T6> getter6, StructuredCodec<T6> codec6)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R.static <T> StructuredCodec<Class<? extends T>>ofClass()static <E extends Enum<E>>
StructuredCodec<E>ofEnum(Class<E> enumType)static <T> StructuredCodec<List<T>>ofList(StructuredCodec<T> valueAdapters)Combinator codec that writes/reads a list of T with given codec for Tstatic <K, V> StructuredCodec<Map<K,V>>ofMap(StructuredCodec<K> codecKey, StructuredCodec<V> codecValue)Combinator codec that writes/reads a map with keys of type K and values of type V with given codecs for K and Vstatic <T> StructuredCodec<@Nullable T>ofNullable(StructuredCodec<T> codec)static <T> StructuredCodec<Map<String,T>>ofObjectMap(Map<String,StructuredCodec<? extends T>> fieldCodecs)Combinator codec that writes/reads a heterogeneous map with string keys and values using codecs from given mapstatic <T> StructuredCodec<Optional<T>>ofOptional(StructuredCodec<T> codec)Combinator codec that writes/reads Optional<T> as nullable T with given codec for Tstatic <T> StructuredCodec<Set<T>>ofSet(StructuredCodec<T> codec)Combinator codec that writes/reads a set of T with given codec for Tstatic StructuredCodec<Object[]>ofTupleArray(StructuredCodec<?>... elementDecoders)Combinator codec that writes/reads a heterogeneous fixed-size array ob objects with given codecsstatic StructuredCodec<Object[]>ofTupleArray(List<StructuredCodec<?>> codecs)static <T> StructuredCodec<List<T>>ofTupleList(StructuredCodec<? extends T>... elementDecoders)static <T> StructuredCodec<List<T>>ofTupleList(List<StructuredCodec<? extends T>> codecs)static <T, R> StructuredCodec<R>transform(StructuredCodec<T> codec, DecoderFunction<T,R> reader, Function<R,T> writer)static <R> StructuredCodec<R>tuple(TupleDecoder0<R> constructor)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type Rstatic <R, T1> StructuredCodec<R>tuple(TupleDecoder1<T1,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type Rstatic <R, T1, T2> StructuredCodec<R>tuple(TupleDecoder2<T1,T2,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type Rstatic <R, T1, T2, T3>
StructuredCodec<R>tuple(TupleDecoder3<T1,T2,T3,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type Rstatic <R, T1, T2, T3, T4>
StructuredCodec<R>tuple(TupleDecoder4<T1,T2,T3,T4,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3, Function<R,T4> getter4, StructuredCodec<T4> codec4)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type Rstatic <R, T1, T2, T3, T4, T5>
StructuredCodec<R>tuple(TupleDecoder5<T1,T2,T3,T4,T5,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3, Function<R,T4> getter4, StructuredCodec<T4> codec4, Function<R,T5> getter5, StructuredCodec<T5> codec5)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type Rstatic <R, T1, T2, T3, T4, T5, T6>
StructuredCodec<R>tuple(TupleDecoder6<T1,T2,T3,T4,T5,T6,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3, Function<R,T4> getter4, StructuredCodec<T4> codec4, Function<R,T5> getter5, StructuredCodec<T5> codec5, Function<R,T6> getter6, StructuredCodec<T6> codec6)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R
-
Field Details
-
BOOLEAN_CODEC
-
CHARACTER_CODEC
-
BYTE_CODEC
-
SHORT_CODEC
-
INT_CODEC
-
LONG_CODEC
-
INT32_CODEC
-
LONG64_CODEC
-
FLOAT_CODEC
-
DOUBLE_CODEC
-
STRING_CODEC
-
BYTES_CODEC
-
VOID_CODEC
-
CLASS_CODEC
-
-
Constructor Details
-
StructuredCodecs
public StructuredCodecs()
-
-
Method Details
-
ofEnum
-
ofClass
-
ofOptional
Combinator codec that writes/reads Optional<T> as nullable T with given codec for T -
ofNullable
-
transform
public static <T, R> StructuredCodec<R> transform(StructuredCodec<T> codec, DecoderFunction<T,R> reader, Function<R,T> writer) -
ofList
Combinator codec that writes/reads a list of T with given codec for T -
ofSet
Combinator codec that writes/reads a set of T with given codec for T -
ofTupleArray
Combinator codec that writes/reads a heterogeneous fixed-size array ob objects with given codecs -
ofTupleArray
-
ofTupleList
public static <T> StructuredCodec<List<T>> ofTupleList(StructuredCodec<? extends T>... elementDecoders) -
ofTupleList
-
ofMap
public static <K, V> StructuredCodec<Map<K,V>> ofMap(StructuredCodec<K> codecKey, StructuredCodec<V> codecValue)Combinator codec that writes/reads a map with keys of type K and values of type V with given codecs for K and V -
ofObjectMap
public static <T> StructuredCodec<Map<String,T>> ofObjectMap(Map<String,StructuredCodec<? extends T>> fieldCodecs)Combinator codec that writes/reads a heterogeneous map with string keys and values using codecs from given map -
concat
-
concat
public static <T> StructuredCodec<List<T>> concat(List<StructuredCodec<? extends T>> elementCodecs)Combinator codec that writes/reads a heterogeneous list using codecs from given list without list boundaries -
tuple
A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
tuple
public static <R, T1> StructuredCodec<R> tuple(TupleDecoder1<T1,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
tuple
public static <R, T1, T2> StructuredCodec<R> tuple(TupleDecoder2<T1,T2,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
tuple
public static <R, T1, T2, T3> StructuredCodec<R> tuple(TupleDecoder3<T1,T2,T3,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
tuple
public static <R, T1, T2, T3, T4> StructuredCodec<R> tuple(TupleDecoder4<T1,T2,T3,T4,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3, Function<R,T4> getter4, StructuredCodec<T4> codec4)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
tuple
public static <R, T1, T2, T3, T4, T5> StructuredCodec<R> tuple(TupleDecoder5<T1,T2,T3,T4,T5,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3, Function<R,T4> getter4, StructuredCodec<T4> codec4, Function<R,T5> getter5, StructuredCodec<T5> codec5)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
tuple
public static <R, T1, T2, T3, T4, T5, T6> StructuredCodec<R> tuple(TupleDecoder6<T1,T2,T3,T4,T5,T6,R> constructor, Function<R,T1> getter1, StructuredCodec<T1> codec1, Function<R,T2> getter2, StructuredCodec<T2> codec2, Function<R,T3> getter3, StructuredCodec<T3> codec3, Function<R,T4> getter4, StructuredCodec<T4> codec4, Function<R,T5> getter5, StructuredCodec<T5> codec5, Function<R,T6> getter6, StructuredCodec<T6> codec6)A DSL to callofTupleList(List)with fixed number of arguments and map it to some result type R -
object
A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs -
object
public static <R, T1> StructuredCodec<R> object(TupleDecoder1<T1,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs -
object
public static <R, T1, T2> StructuredCodec<R> object(TupleDecoder2<T1,T2,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs -
object
public static <R, T1, T2, T3> StructuredCodec<R> object(TupleDecoder3<T1,T2,T3,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs -
object
public static <R, T1, T2, T3, T4> StructuredCodec<R> object(TupleDecoder4<T1,T2,T3,T4,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3, String field4, Function<R,T4> getter4, StructuredCodec<T4> codec4)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs -
object
public static <R, T1, T2, T3, T4, T5> StructuredCodec<R> object(TupleDecoder5<T1,T2,T3,T4,T5,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3, String field4, Function<R,T4> getter4, StructuredCodec<T4> codec4, String field5, Function<R,T5> getter5, StructuredCodec<T5> codec5)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs -
object
public static <R, T1, T2, T3, T4, T5, T6> StructuredCodec<R> object(TupleDecoder6<T1,T2,T3,T4,T5,T6,R> constructor, String field1, Function<R,T1> getter1, StructuredCodec<T1> codec1, String field2, Function<R,T2> getter2, StructuredCodec<T2> codec2, String field3, Function<R,T3> getter3, StructuredCodec<T3> codec3, String field4, Function<R,T4> getter4, StructuredCodec<T4> codec4, String field5, Function<R,T5> getter5, StructuredCodec<T5> codec5, String field6, Function<R,T6> getter6, StructuredCodec<T6> codec6)A DSL to callofObjectMap(Map)with fixed number of key-value pairs and map it to some result type R. This is the main combinator for POJO codecs
-