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.LinkedHashMap;
import java.util.Map;

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

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

    public final int version;
    public final Map<String, String> extensionData;

    public SshFxpVersion(int version, Map<String, String> extensionData) {
        this.version = version;

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

    public SshFxpVersion(int version) {
        this(version, new LinkedHashMap<String, String>());
    }

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

    @Override
    public String toString() {
        return "SshFxpVersion {"
                + "version=" + this.version
                + ", extensionData=" + this.extensionData
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
