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 SshFxpExtendedReplyCheckFileName
        extends SshFxpExtendedReply<SshFxpExtendedReplyCheckFileName.Handler> {

    public final String hashAlgorithmUsed;
    public final byte[] data;

    public SshFxpExtendedReplyCheckFileName(int id, String hashAlgorithmUsed, byte[] data) {
        super(id);

        assertNotNull(hashAlgorithmUsed);
        this.hashAlgorithmUsed = hashAlgorithmUsed;

        assertNotNull(data);
        this.data = data;
    }

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

    @Override
    public String toString() {
        return "SshFxpExtendedReplyCheckFileName {"
               + "id=" + this.id
               + ", hashAlgorithmUsed='" + this.hashAlgorithmUsed + '\''
               + ", data=" + Arrays.toString(this.data)
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
