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

com.atlassian.bamboo.specs.api.builders.jobcache.JobCache Maven / Gradle / Ivy

There is a newer version: 2.1.7
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy