io.github.eliux.mega.cmd.MegaCmdPutMultiple 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 io.github.eliux.mega.error.MegaWrongArgumentsException;
import java.util.*;
public class MegaCmdPutMultiple extends AbstractMegaCmdPut {
private String remotePath;
private List localFiles;
public MegaCmdPutMultiple(String remotePath, String... localFiles) {
this.remotePath = remotePath;
this.localFiles = new ArrayList<>(Arrays.asList(localFiles));
}
public String getRemotePath() {
return remotePath;
}
public MegaCmdPutMultiple setRemotePath(String remotePath) {
if (remotePath != null) {
this.remotePath = remotePath;
}
return this;
}
public List localFiles() {
return localFiles;
}
private List cmdLocalFilesParams() {
if (localFiles == null || localFiles.isEmpty()) {
throw new MegaWrongArgumentsException(
"There are not local files specified!"
);
}
return Collections.unmodifiableList(localFiles);
}
@Override
protected List cmdFileParams() {
List result = new LinkedList<>(localFiles);
result.add(getRemotePath());
return result;
}
public void addLocalFileToUpload(String filename) {
localFiles.add(filename);
}
}