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

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

import java.util.Arrays;

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

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

    public final int id;
    public final byte[] handle;
    public final FileAttributeFlags flags;

    public SshFxpFstat(int id, byte[] handle, FileAttributeFlags flags) {
        this.id = id;

        assertNotNull(handle);
        this.handle = handle;

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

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

    @Override
    public String toString() {
        return "SshFxpFstat {"
               + "id=" + this.id
               + ", handle=" + Arrays.toString(this.handle)
               + ", flags=" + this.flags
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
