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 SshFxpName
        extends Message<SshFxpName.Handler> {

    public final int id;
    public final NameEntry[] entries;

    public SshFxpName(int id, NameEntry... entries) {
        this.id = id;

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

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

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

    public interface Handler
            extends Message.HandlerBase {

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

    }

}
