package com.jscape.inet.sftp.protocol.v4.messages;

import com.jscape.inet.sftp.protocol.messages.Message;
import com.jscape.util.net.connection.MessageConnection;

import java.util.Arrays;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * @author Alex Usun
 */
public class SshFxpExtendedTextSeek
        extends SshFxpExtended<SshFxpExtendedTextSeek.Handler> {

    public final byte[] fileHandle;
    public final long lineNumber;

    public SshFxpExtendedTextSeek(int id, byte[] fileHandle, long lineNumber) {
        super(id);

        assertNotNull(fileHandle);
        this.fileHandle = fileHandle;

        this.lineNumber = lineNumber;
    }

    @Override
    public void accept(Handler handler, MessageConnection<Message> connection) {
        handler.handle(this, connection);
    }

    @Override
    public String toString() {
        return "SshFxpExtendedTextSeek {"
               + "id=" + this.id
               + ", fileHandle=" + Arrays.toString(this.fileHandle)
               + ", lineNumber=" + this.lineNumber
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

        void handle(SshFxpExtendedTextSeek message, MessageConnection<Message> connection);

    }
}
