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

    public final int id;
    public final String path;
    public final FileAttributeFlags flags;

    public SshFxpLstat(int id, String path, FileAttributeFlags flags) {
        this.id = id;

        assertNotNull(path);
        this.path = path;

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

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

    @Override
    public String toString() {
        return "SshFxpLstat {"
               + "id=" + this.id
               + ", path='" + this.path + '\''
               + ", flags=" + this.flags
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
