All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.eliux.mega.cmd.MegaCmdGet Maven / Gradle / Ivy

Go to download

Java client library that works on top of MEGAcmd to provide access to the services of Mega.nz

The newest version!
package io.github.eliux.mega.cmd;

import java.util.LinkedList;
import java.util.List;
import java.util.Optional;

public class MegaCmdGet extends AbstractMegaCmdPathHandler {

    private String remotePath;

    private Optional localPath;

    public MegaCmdGet(String remotePath) {
        this.remotePath = remotePath;
        this.localPath = Optional.empty();
    }

    public MegaCmdGet(String remotePath, String localPath) {
        this.remotePath = remotePath;
        this.localPath = Optional.of(localPath);
    }

    public String getRemotePath() {
        return remotePath;
    }

    public MegaCmdGet setRemotePath(String remotePath) {
        this.remotePath = remotePath;
        return this;
    }

    public Optional getLocalPath() {
        return localPath;
    }

    public MegaCmdGet setLocalPath(String localPath) {
        this.localPath = Optional.of(localPath);
        return this;
    }

    public MegaCmdGet useCurrentFolder() {
        this.localPath = Optional.empty();
        return this;
    }

    @Override
    public String getCmd() {
        return "get";
    }

    @Override
    protected List cmdFileParams() {
        List cmdFileParams = new LinkedList<>();

        cmdFileParams.add(getRemotePath());

        getLocalPath().ifPresent(cmdFileParams::add);

        return cmdFileParams;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy