aboutsummaryrefslogtreecommitdiffstats
path: root/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceId.java
blob: a4bfeebef4fa8e372b7af806f6ad3319634d73cc (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.service.monitor;

import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceType;

import java.util.Objects;

/**
 * Identifies a service. Immutable.
 *
 * @author hakon
 */
public class ServiceId {
    private final ApplicationId applicationId;
    private final ClusterId clusterId;
    private final ServiceType serviceType;
    private final ConfigId configId;

    public ServiceId(ApplicationId applicationId,
                     ClusterId clusterId,
                     ServiceType serviceType,
                     ConfigId configId) {
        this.applicationId = applicationId;
        this.clusterId = clusterId;
        this.serviceType = serviceType;
        this.configId = configId;
    }

    public ApplicationId getApplicationId() {
        return applicationId;
    }

    public ClusterId getClusterId() {
        return clusterId;
    }

    public ServiceType getServiceType() {
        return serviceType;
    }

    public ConfigId getConfigId() {
        return configId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ServiceId serviceId = (ServiceId) o;
        return Objects.equals(applicationId, serviceId.applicationId) &&
                Objects.equals(clusterId, serviceId.clusterId) &&
                Objects.equals(serviceType, serviceId.serviceType) &&
                Objects.equals(configId, serviceId.configId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(applicationId, clusterId, serviceType, configId);
    }

    @Override
    public String toString() {
        return "ServiceId{" +
                "applicationId=" + applicationId +
                ", clusterId=" + clusterId +
                ", serviceType=" + serviceType +
                ", configId=" + configId +
                '}';
    }
}