CavalliumDBEngine/src/main/java/it/cavallium/dbengine/database/collections/FixedLengthSerializer.java
2021-01-31 22:54:26 +01:00

28 lines
595 B
Java

package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
public interface FixedLengthSerializer<B> extends Serializer<B> {
int getLength();
static FixedLengthSerializer<ByteBuf> noop(int length) {
return new FixedLengthSerializer<>() {
@Override
public ByteBuf deserialize(ByteBuf serialized) {
return serialized.readSlice(length);
}
@Override
public void serialize(ByteBuf deserialized, ByteBuf output) {
output.writeBytes(deserialized.slice(), length);
}
@Override
public int getLength() {
return length;
}
};
}
}