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.Arrays;

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

/**
 * @author Alex Usun
 */
public class SshFxpHandle
        extends Message<SshFxpHandle.Handler> {

    public final int id;
    public final byte[] handle;

    public SshFxpHandle(int id, byte[] handle) {
        this.id = id;

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

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

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

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
