package com.jscape.inet.scp.protocol.messages;

import com.jscape.util.net.connection.SyncRawConnection;

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

/**
 * @author Alex Usun
 */
public class WriteDirectoryCommand
        extends Command<WriteDirectoryCommand.Handler> {

    public final String path;
    public final boolean preserveAttributes;

    public WriteDirectoryCommand(String path, boolean preserveAttributes) {
        assertNotNull(path);
        this.path = path;

        this.preserveAttributes = preserveAttributes;
    }

    @Override
    public void accept(Handler handler, SyncRawConnection connection) {
        handler.handle(this, connection);
    }

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

    public interface Handler
            extends Command.HandlerBase {

        void handle(WriteDirectoryCommand command, SyncRawConnection connection);

    }
}
