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

brooklyn.entity.drivers.downloads.BasicDownloadResolver Maven / Gradle / Ivy

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.entity.drivers.downloads;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.List;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;

public class BasicDownloadResolver implements DownloadResolver {

    private final List targets;
    private final String filename;
    private final String unpackDirectoryName;

    public BasicDownloadResolver(Iterable targets, String filename) {
        this(targets, filename, null);
    }
    
    public BasicDownloadResolver(Iterable targets, String filename, String unpackDirectoryName) {
        this.targets = ImmutableList.copyOf(checkNotNull(targets, "targets"));
        this.filename = checkNotNull(filename, "filename");
        this.unpackDirectoryName = unpackDirectoryName;
    }
    
    @Override
    public List getTargets() {
        return targets;
    }

    @Override
    public String getFilename() {
        return filename;
    }

    @Override
    public String getUnpackedDirectoryName(String defaultVal) {
        return unpackDirectoryName == null ? defaultVal : unpackDirectoryName;
    }
    
    @Override
    public String toString() {
        return Objects.toStringHelper(this).add("targets", targets).add("filename", filename)
                .add("unpackDirName", unpackDirectoryName).omitNullValues().toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy