aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-zone-api/src/main/java/ai/vespa/cloud/ApplicationId.java
blob: 46780d17a138b69c5088111ba8cdc46b34c69505 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.cloud;

import java.util.Objects;

/**
 * The application id this is running as.
 * This is a combination of a tenant, application, and instance name.
 *
 * @author bratseth
 */
public class ApplicationId {

    private final String tenant;
    private final String application;
    private final String instance;

    public ApplicationId(String tenant, String application, String instance) {
        this.tenant = tenant;
        this.application = application;
        this.instance = instance;
    }

    public String tenant() { return tenant; }
    public String application() { return application; }
    public String instance() { return instance; }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if ( ! (o instanceof ApplicationId)) return false;
        ApplicationId other = (ApplicationId)o;
        if ( ! other.tenant.equals(this.tenant)) return false;
        if ( ! other.application.equals(this.application)) return false;
        if ( ! other.instance.equals(this.instance)) return false;
        return true;
    }

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

    /** Returns the string tenant.application.instance */
    @Override
    public String toString() { return tenant + "." + application + "." + instance; }

}