package com.jscape.inet.sftp.protocol.v3.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 SshFxpRename
        extends Message<SshFxpRename.Handler> {

    public final int id;
    public final String oldPath;
    public final String newPath;

    public SshFxpRename(int id, String oldPath, String newPath) {
        this.id = id;

        assertNotNull(oldPath);
        this.oldPath = oldPath;

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

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

    @Override
    public String toString() {
        return "SshFxpRename {"
                + "id=" + this.id
                + ", oldPath='" + this.oldPath + '\''
                + ", newPath='" + this.newPath + '\''
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
