io.datakernel.codec.StructuredDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datakernel-codec Show documentation
Show all versions of datakernel-codec Show documentation
Tools for encoding/decoding of primitives and objects.
package io.datakernel.codec;
import io.datakernel.common.parse.ParseException;
import java.util.function.Supplier;
/**
* Encorer can read an object of type T from a {@link StructuredInput}.
*/
public interface StructuredDecoder {
T decode(StructuredInput in) throws ParseException;
static StructuredDecoder ofObject(StructuredDecoder decoder) {
return in -> in.readObject(decoder);
}
static StructuredDecoder ofObject(Supplier supplier) {
return ofObject(in -> supplier.get());
}
static StructuredDecoder ofTuple(StructuredDecoder decoder) {
return in -> in.readTuple(decoder);
}
}