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

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

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

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

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

    public SshFxpExtendedUnknown(int id, String type, byte[] data) {
        super(id);

        assertNotNull(type);
        this.type = type;

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

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

    @Override
    public String toString() {
        return "SshFxpExtendedUnknown {"
               + "id=" + this.id
               + ", type='" + this.type + '\''
               + ", data.length=" + this.data.length
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
