package io.atomix.storage.journal;
import io.netty.buffer.ByteBuf;
+import java.io.IOException;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
- * Support for serialization of {@link ByteBufJournal} entries.
+ * Support for mapping of {@link ByteBufJournal} entries to and from {@link ByteBuf}s.
*/
@NonNullByDefault
public interface ByteBufMapper<T> {
/**
- * Converts an object into a series of bytes in a {@link ByteBuf}.
+ * Converts the contents of a {@link ByteBuf} to an object.
*
- * @param obj the object
- * @return resulting buffer
+ * @param index entry index
+ * @param bytes entry bytes
+ * @return resulting object
*/
- ByteBuf objectToBytes(T obj) ;
+ T bytesToObject(final long index, ByteBuf bytes);
/**
- * Converts the contents of a {@link ByteBuf} to an object.
+ * Converts an object into a series of bytes in the specified {@link ByteBuf}.
*
- * @param buf buffer to convert
- * @return resulting object
+ * @param obj the object
+ * @param buf target buffer
+ * @throws IOException if an I/O error occurs
*/
- T bytesToObject(ByteBuf buf);
+ void objectToBytes(T obj, ByteBuf buf) throws IOException;
}