com.heroku.sdk.deploy.lib.sourceblob.SourceBlobDescriptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of heroku-deploy Show documentation
Show all versions of heroku-deploy Show documentation
Library for deploying Java applications to Heroku
package com.heroku.sdk.deploy.lib.sourceblob;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
public class SourceBlobDescriptor {
private Map contents = new HashMap<>();
public SourceBlobDescriptor() {
}
private SourceBlobDescriptor(Map contents) {
this.contents = contents;
}
public void addLocalPath(Path sourceBlobPath, Path localPath, boolean hidden) {
contents.put(sourceBlobPath, SourceBlobContent.fromLocalPath(localPath, hidden));
}
public void addLocalPath(String sourceBlobPath, Path localPath, boolean hidden) {
addLocalPath(Paths.get(sourceBlobPath), localPath, hidden);
}
public void addSyntheticFile(Path sourceBlobPath, String stringContent, boolean hidden) {
contents.put(sourceBlobPath, SourceBlobContent.fromString(stringContent, hidden));
}
public void addSyntheticFile(String sourceBlobPath, String stringContent, boolean hidden) {
addSyntheticFile(Paths.get(sourceBlobPath), stringContent, hidden);
}
public Map getContents() {
return new HashMap<>(contents);
}
static class SourceBlobContent {
private Path localPath;
private String syntheticFileContents;
private boolean hidden = false;
public static SourceBlobContent fromLocalPath(Path localPath, boolean hidden) {
SourceBlobContent sourceBlobContent = new SourceBlobContent();
sourceBlobContent.localPath = localPath;
sourceBlobContent.hidden = hidden;
return sourceBlobContent;
}
public static SourceBlobContent fromString(String syntheticFileContents, boolean hidden) {
SourceBlobContent sourceBlobContent = new SourceBlobContent();
sourceBlobContent.syntheticFileContents = syntheticFileContents;
sourceBlobContent.hidden = hidden;
return sourceBlobContent;
}
public boolean isLocalPath() {
return localPath != null;
}
public boolean isSyntheticFile() {
return syntheticFileContents != null;
}
public Path getLocalPath() {
return localPath;
}
public String getSyntheticFileContents() {
return syntheticFileContents;
}
public boolean isHidden() {
return hidden;
}
}
}