// Path: src/main/java/org/tools4j/hoverraft/command/Command.java
// public interface Command extends DirectPayload, Event {
// 
//     CommandKey commandKey();
// 
//     CommandPayload commandPayload();
// 
//     default Command sourceId(final int sourceId) {
//         commandKey().sourceId(sourceId);
//         return this;
//     }
// 
//     default Command commandIndex(final long commandIndex) {
//         commandKey().commandIndex(commandIndex);
//         return this;
//     }
// 
//     default void copyFrom(final Command command) {
//         writeBufferOrNull().putBytes(offset(), command.readBufferOrNull(), command.offset(), command.byteLength());
//     }
// 
//     @Override
//     default Transition accept(final ServerContext serverContext, final EventHandler eventHandler) {
//         return eventHandler.onCommand(serverContext, this);
//     }
// 
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/CommandKey.java
// public interface CommandKey extends Comparable<CommandKey> {
//     Comparator<CommandKey> COMPARATOR = (k1, k2) -> {
//         final int sourceCompare = Integer.compare(k1.sourceId(), k2.sourceId());
//         return sourceCompare == 0 ? Long.compare(k1.commandIndex(), k2.commandIndex()) : sourceCompare;
//     };
// 
//     int sourceId();
//     CommandKey sourceId(int sourceId);
// 
//     long commandIndex();
//     CommandKey commandIndex(long commandIndex);
// 
//     @Override
//     default int compareTo(final CommandKey other) {
//         return COMPARATOR.compare(this, other);
//     }
// 
//     default boolean containedIn(final CommandLog commandLog) {
//         return commandLog.contains(this);
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/DirectLogEntry.java
// public class DirectLogEntry extends AbstractDirectPayload implements LogEntry {
//     public static final int EMPTY_COMMAND_BYTE_LENGTH = DirectLogKey.BYTE_LENGTH + DirectCommand.EMPTY_COMMAND_BYTE_LENGTH;
//     private static final int LOG_KEY_OFF = 0;
//     private static final int LOG_KEY_LEN = DirectLogKey.BYTE_LENGTH;
// 
//     private static final int COMMAND_OFF = LOG_KEY_OFF + LOG_KEY_LEN;
// 
//     private DirectLogKey directLogKey = new DirectLogKey();
//     private DirectCommand directCommand = new DirectCommand();
// 
//     @Override
//     public void wrap(final DirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void wrap(final MutableDirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void unwrap() {
//         directLogKey.unwrap();
//         directCommand.unwrap();
//         super.unwrap();
//     }
// 
// 
//     @Override
//     public Command command() {
//         return directCommand;
//     }
// 
//     @Override
//     public LogKey logKey() {
//         return directLogKey;
//     }
// 
//     @Override
//     public int byteLength() {
//         return COMMAND_OFF + directCommand.byteLength();
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/LogEntry.java
// public interface LogEntry extends DirectPayload {
//     LogKey logKey();
// 
//     default LogEntry term(final int term) {
//         logKey().term(term);
//         return this;
//     }
//     default LogEntry index(final long index) {
//         logKey().index(index);
//         return this;
//     }
// 
//     Command command();
// 
//     default void copyFrom(final LogEntry logEntry) {
//         writeBufferOrNull().putBytes(offset(), logEntry.readBufferOrNull(), logEntry.offset(), logEntry.byteLength());
//     }
// }


import org.tools4j.hoverraft.command.Command;
import org.tools4j.hoverraft.command.CommandKey;
import org.tools4j.hoverraft.command.DirectLogEntry;
import org.tools4j.hoverraft.command.LogEntry;
import org.tools4j.hoverraft.message.*;
import org.tools4j.hoverraft.message.direct.*;
    private final CommandKey commandKey = new DirectCommandKey();
    private final Command command = new DirectCommand();
    private final LogEntry logEntry = new DirectLogEntry();

    @Override
    public AppendRequest appendRequest() {
        return appendRequest;
    }

    @Override
    public AppendResponse appendResponse() {
        return appendResponse;
    }

    @Override
    public VoteRequest voteRequest() {
        return voteRequest;
    }

    @Override
    public VoteResponse voteResponse() {
        return voteResponse;
    }

    @Override
    public TimeoutNow timeoutNow() {
        return timeoutNow;
    }

    @Override
// Path: src/main/java/org/tools4j/hoverraft/command/Command.java
// public interface Command extends DirectPayload, Event {
// 
//     CommandKey commandKey();
// 
//     CommandPayload commandPayload();
// 
//     default Command sourceId(final int sourceId) {
//         commandKey().sourceId(sourceId);
//         return this;
//     }
// 
//     default Command commandIndex(final long commandIndex) {
//         commandKey().commandIndex(commandIndex);
//         return this;
//     }
// 
//     default void copyFrom(final Command command) {
//         writeBufferOrNull().putBytes(offset(), command.readBufferOrNull(), command.offset(), command.byteLength());
//     }
// 
//     @Override
//     default Transition accept(final ServerContext serverContext, final EventHandler eventHandler) {
//         return eventHandler.onCommand(serverContext, this);
//     }
// 
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/CommandKey.java
// public interface CommandKey extends Comparable<CommandKey> {
//     Comparator<CommandKey> COMPARATOR = (k1, k2) -> {
//         final int sourceCompare = Integer.compare(k1.sourceId(), k2.sourceId());
//         return sourceCompare == 0 ? Long.compare(k1.commandIndex(), k2.commandIndex()) : sourceCompare;
//     };
// 
//     int sourceId();
//     CommandKey sourceId(int sourceId);
// 
//     long commandIndex();
//     CommandKey commandIndex(long commandIndex);
// 
//     @Override
//     default int compareTo(final CommandKey other) {
//         return COMPARATOR.compare(this, other);
//     }
// 
//     default boolean containedIn(final CommandLog commandLog) {
//         return commandLog.contains(this);
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/DirectLogEntry.java
// public class DirectLogEntry extends AbstractDirectPayload implements LogEntry {
//     public static final int EMPTY_COMMAND_BYTE_LENGTH = DirectLogKey.BYTE_LENGTH + DirectCommand.EMPTY_COMMAND_BYTE_LENGTH;
//     private static final int LOG_KEY_OFF = 0;
//     private static final int LOG_KEY_LEN = DirectLogKey.BYTE_LENGTH;
// 
//     private static final int COMMAND_OFF = LOG_KEY_OFF + LOG_KEY_LEN;
// 
//     private DirectLogKey directLogKey = new DirectLogKey();
//     private DirectCommand directCommand = new DirectCommand();
// 
//     @Override
//     public void wrap(final DirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void wrap(final MutableDirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void unwrap() {
//         directLogKey.unwrap();
//         directCommand.unwrap();
//         super.unwrap();
//     }
// 
// 
//     @Override
//     public Command command() {
//         return directCommand;
//     }
// 
//     @Override
//     public LogKey logKey() {
//         return directLogKey;
//     }
// 
//     @Override
//     public int byteLength() {
//         return COMMAND_OFF + directCommand.byteLength();
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/LogEntry.java
// public interface LogEntry extends DirectPayload {
//     LogKey logKey();
// 
//     default LogEntry term(final int term) {
//         logKey().term(term);
//         return this;
//     }
//     default LogEntry index(final long index) {
//         logKey().index(index);
//         return this;
//     }
// 
//     Command command();
// 
//     default void copyFrom(final LogEntry logEntry) {
//         writeBufferOrNull().putBytes(offset(), logEntry.readBufferOrNull(), logEntry.offset(), logEntry.byteLength());
//     }
// }


// Path: src/main/java/org/tools4j/hoverraft/direct/RecyclingDirectFactory.java
import org.tools4j.hoverraft.command.Command;
import org.tools4j.hoverraft.command.CommandKey;
import org.tools4j.hoverraft.command.DirectLogEntry;
import org.tools4j.hoverraft.command.LogEntry;
import org.tools4j.hoverraft.message.*;
import org.tools4j.hoverraft.message.direct.*;

    private final CommandKey commandKey = new DirectCommandKey();
    private final Command command = new DirectCommand();
    private final LogEntry logEntry = new DirectLogEntry();

    @Override
    public AppendRequest appendRequest() {
        return appendRequest;
    }

    @Override
    public AppendResponse appendResponse() {
        return appendResponse;
    }

    @Override
    public VoteRequest voteRequest() {
        return voteRequest;
    }

    @Override
    public VoteResponse voteResponse() {
        return voteResponse;
    }

    @Override
    public TimeoutNow timeoutNow() {
        return timeoutNow;
    }

    @Override
    public CommandKey commandKey() {