summaryrefslogtreecommitdiffstats
path: root/config-model-api/src/main/java/com/yahoo/config/model/api/HostInfo.java
blob: dcb875d02b5702c04b2c252111323cd4fd05c49a (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.api;

import java.util.Collection;

/*
 * Contains information about a host and what services are running on it.
 *
 * @author lulf
 * @since 5.37
 */
public class HostInfo {

    private final String hostname;
    private final Collection<ServiceInfo> services;

    public HostInfo(String hostName, Collection<ServiceInfo> services) {
        this.hostname = hostName;
        this.services = services;
    }

    public String getHostname() {
        return hostname;
    }

    public Collection<ServiceInfo> getServices() {
        return services;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        HostInfo hostInfo = (HostInfo) o;

        if (!hostname.equals(hostInfo.hostname)) return false;
        if (services != null ? !services.equals(hostInfo.services) : hostInfo.services != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = hostname.hashCode();
        result = 31 * result + (services != null ? services.hashCode() : 0);
        return result;
    }

}