com.atlassian.bamboo.specs.api.builders.jobcache.JobCache Maven / Gradle / Ivy
package com.atlassian.bamboo.specs.api.builders.jobcache;
import com.atlassian.bamboo.specs.api.builders.plan.configuration.PluginConfiguration;
import com.atlassian.bamboo.specs.api.model.jobcache.CacheItemProperties;
import com.atlassian.bamboo.specs.api.model.jobcache.JobCacheProperties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* Define cache locations to carry from previous job result to the next.
*/
public class JobCache extends PluginConfiguration {
private final List caches = new ArrayList<>();
public JobCache() {}
public JobCache caches(CacheItem... caches) {
caches(Arrays.asList(caches));
return this;
}
public JobCache caches(List caches) {
caches.stream().map(CacheItem::build).forEach(this.caches::add);
return this;
}
@Override
protected JobCacheProperties build() {
return new JobCacheProperties(caches);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof JobCache)) {
return false;
}
JobCache that = (JobCache) o;
return Objects.equals(caches, that.caches);
}
@Override
public int hashCode() {
return Objects.hash(caches);
}
}