aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/SourceRevision.java
blob: 1f7be73a68ef2d51c8f34e21e9aea79bacbeaeab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.deployment;

import java.util.Objects;

/**
 * A revision in a source repository
 * 
 * @author bratseth
 */
public class SourceRevision {

    private final String repository;
    private final String branch;
    private final String commit;
    
    public SourceRevision(String repository, String branch, String commit) {
        Objects.requireNonNull(repository, "repository cannot be null");
        Objects.requireNonNull(branch, "branch cannot be null");
        Objects.requireNonNull(commit, "commit cannot be null");
        this.repository = repository;
        this.branch = branch;
        this.commit = commit;
    }
    
    public String repository() { return repository; }
    public String branch() { return branch; }
    public String commit() { return commit; }
    
    @Override
    public int hashCode() { return Objects.hash(repository, branch, commit); }
    
    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if ( ! (o instanceof SourceRevision)) return false;

        SourceRevision other = (SourceRevision)o;
        return this.repository.equals(other.repository) && 
               this.branch.equals(other.branch) && 
               this.commit.equals(other.commit);
    }
    
    @Override
    public String toString() { return "source revision of repository '" + repository + 
                                      "', branch '" + branch + "' with commit '" + commit  + "'"; }

}