aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobId.java
blob: 8e809fab5666696da145ee019c27fdd0afa45dc7 (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
// 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 com.yahoo.config.provision.ApplicationId;

import java.util.Objects;

/**
 * Immutable ID of a job that may be run.
 *
 * @author jonmv
 */
public class JobId {

    private final ApplicationId application;
    private final JobType type;

    public JobId(ApplicationId application, JobType type) {
        this.application = Objects.requireNonNull(application, "ApplicationId cannot be null!");
        this.type = Objects.requireNonNull(type, "JobType cannot be null!");
    }

    public ApplicationId application() { return application; }
    public JobType type() { return type; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        JobId jobId = (JobId) o;
        return application.equals(jobId.application) &&
               type.equals(jobId.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(application, type);
    }

    @Override
    public String toString() {
        return  type.jobName() + " for " + application;
    }

}