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

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

import java.util.List;

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

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

    public final String name;
    public final List<String> hashAlgorithmList;
    public final long startOffset;
    public final long length;
    public final int blockSize;

    public SshFxpExtendedCheckFileName(int id, String name, List<String> hashAlgorithmList, long startOffset, long length, int blockSize) {
        super(id);

        assertNotNull(name);
        this.name = name;

        assertNotNull(hashAlgorithmList);
        this.hashAlgorithmList = hashAlgorithmList;

        this.startOffset = startOffset;
        this.length = length;
        this.blockSize = blockSize;
    }

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

    @Override
    public String toString() {
        return "SshFxpExtendedCheckFileName {"
               + "id=" + this.id
               + ", name='" + this.name + '\''
               + ", hashAlgorithmList=" + this.hashAlgorithmList
               + ", startOffset=" + this.startOffset
               + ", length=" + this.length
               + ", blockSize=" + this.blockSize
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
