io.github.eliux.mega.cmd.MegaCmdGet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of megacmd4j Show documentation
Show all versions of megacmd4j Show documentation
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;
}
}