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

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

/**
 * File message.
 *
 * @author Alex Usun
 */
public class FileMessage
        extends Message {

    public final String fileName;
    public final long fileLength;
    public final String fileMode;

    /**
     * Creates a new message instance.
     *
     * @param fileName   file name
     * @param fileLength file length in bytes
     * @param fileMode   file mode
     */
    public FileMessage(String fileName, long fileLength, String fileMode) {
        assertNotNull(fileName);
        this.fileName = fileName;

        assertGreaterOrEqual(fileLength, 0, "Bad file length value.");
        this.fileLength = fileLength;

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

    @Override
    public String toString() {
        return "FileMessage {"
               + "fileName='" + this.fileName + '\''
               + ", fileLength=" + this.fileLength
               + ", fileMode='" + this.fileMode + '\''
               + '}';
    }
}
