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

    public final int id;
    public final byte[] handle;
    public final FileAttributes attributes;

    public SshFxpFsetStat(int id, byte[] handle, FileAttributes attributes) {
        this.id = id;

        assertNotNull(handle);
        this.handle = handle;

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

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

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

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
