aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/Artifact.java
blob: 2c1ea1cb3a7209834f7f7fc90dd60cae65279c60 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// 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.artifact;

import com.yahoo.component.Version;

import java.time.Instant;
import java.util.Objects;

/**
 * A registry artifact (e.g. container image or RPM)
 *
 * @author mpolden
 */
public class Artifact {

    private final String id;
    private final String registry;
    private final String repository;
    private final String tag;
    private final Instant createdAt;
    private final Version version;

    public Artifact(String id, String registry, String repository, String tag, Instant createdAt, Version version) {
        this.id = Objects.requireNonNull(id);
        this.registry = Objects.requireNonNull(registry);
        this.repository = Objects.requireNonNull(repository);
        this.tag = Objects.requireNonNull(tag);
        this.createdAt = Objects.requireNonNull(createdAt);
        this.version = Objects.requireNonNull(version);
    }

    /** Unique identifier of this */
    public String id() {
        return id;
    }

    /** The registry holding this artifact */
    public String registry() {
        return registry;
    }

    /** Repository of this artifact */
    public String repository() {
        return repository;
    }

    /** Tag of this artifact */
    public String tag() {
        return tag;
    }

    /** The time this was created */
    public Instant createdAt() {
        return createdAt;
    }

    /** The version of this */
    public Version version() {
        return version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Artifact that = (Artifact) o;
        return id.equals(that.id) &&
               registry.equals(that.registry) &&
               repository.equals(that.repository) &&
               tag.equals(that.tag) &&
               createdAt.equals(that.createdAt) &&
               version.equals(that.version);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, registry, repository, tag, createdAt, version);
    }

    @Override
    public String toString() {
        return "artifact " + registry + "/" + repository + " [version=" + version.toFullString() + ",createdAt=" + createdAt + ",tag=" + tag + "]";
    }
}