Interface StorageCodec<T>
public interface StorageCodec<T>
Encodes values to
DataValues and back. Decoding never throws for bad data; it returns an
error Result (usually a MachineError.SerializationError).
Persisted data must go through a VersionedCodec so it can be migrated later.
-
Method Summary
Modifier and TypeMethodDescription@NotNull DataValuedefault <R> @NotNull StorageCodec<R> flatXmap(@NotNull Function<? super T, Result<R>> to, @NotNull Function<? super R, ? extends T> from) Maps this codec to another type when decoding may fail.static <T> @NotNull StorageCodec<T> of(@NotNull Function<? super T, ? extends DataValue> encoder, @NotNull Function<? super DataValue, Result<T>> decoder) default <R> @NotNull StorageCodec<R> Maps this codec to another type with a total, two-way conversion.
-
Method Details
-
encode
-
decode
-
of
-
xmap
@NotNull default <R> @NotNull StorageCodec<R> xmap(@NotNull @NotNull Function<? super T, ? extends R> to, @NotNull @NotNull Function<? super R, ? extends T> from) Maps this codec to another type with a total, two-way conversion. -
flatXmap
-