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

    public final int id;
    public final int code;
    public final String message;
    public final String languageTag;

    public SshFxpStatus(int id, int code, String message, String languageTag) {
        this.id = id;
        this.code = code;

        assertNotNull(message);
        this.message = message;

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

    public SshFxpStatus(int id, StatusCode statusCode, String message, String languageTag) {
        this(id, statusCode.code, message, languageTag);
    }

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

    @Override
    public String toString() {
        return "SshFxpStatus {"
                + "id=" + this.id
                + ", code=" + this.code
                + ", message='" + this.message + '\''
                + ", languageTag='" + this.languageTag + '\''
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
