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

net.thucydides.core.model.Release Maven / Gradle / Ivy

package net.thucydides.core.model;

import com.google.common.collect.ImmutableList;

import java.util.List;

/**
 * A release or version of a software project.
 * Releases are identified by a tag, usually of type 'version'
 */
public class Release implements Comparable {
    private final TestTag releaseTag;
    private final List children;
    private final String label;
    private final String reportName;
    private final List parents;

    public static Release ofVersion(String versionName) {
        return new Release(TestTag.withName(versionName).andType("version"));
    }
    public Release(TestTag releaseTag) {
        this.releaseTag = releaseTag;
        this.label = releaseTag.getName();
        this.children = ImmutableList.of();
        this.parents = ImmutableList.of();
        this.reportName = null;
    }

    public Release(TestTag releaseTag, List children, List parents, String reportName) {
        this.releaseTag = releaseTag;
        this.label = releaseTag.getName();
        this.children = ImmutableList.copyOf(children);
        this.parents = ImmutableList.copyOf(parents);
        this.reportName = reportName;
    }

    public Release withChildren(List children) {
        return new Release(releaseTag, children, parents, reportName);
    }

    public Release withParents(List parents) {
        return new Release(releaseTag, children, parents, reportName);
    }

    public Release withReport(String reportName) {
        return new Release(releaseTag, children, parents, reportName);
    }
    public String getName() {
        return releaseTag.getName();
    }

    public String getLabel() {
        return label;
    }

    public List getChildren() {
        return children;
    }

    public List getParents() {
        return parents;
    }

    public TestTag getReleaseTag() {
        return releaseTag;
    }

    public String getReportName() {
        return reportName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Release release = (Release) o;

        if (!releaseTag.equals(release.releaseTag)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return releaseTag.hashCode();
    }

    @Override
    public int compareTo(Object otherRelease) {
        return getName().compareTo(((Release) otherRelease).getName());
    }

    @Override
    public String toString() {
        return "Release{" +
                "label='" + label + '\'' +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy