blob: 6d72da7df6f961cf694f82d304bc0790e0f1940a (
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
85
86
87
|
// Copyright 2016 Yahoo Inc. 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.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Collection;
/**
* Contains information about a service.
*
* @author lulf
* @since 5.37
*/
public class ServiceInfo {
private final String serviceName;
private final String serviceType;
private final Collection<PortInfo> ports;
private final Map<String, String> properties;
private final String configId;
private final String hostName;
public ServiceInfo(String serviceName, String serviceType, Collection<PortInfo> ports, Map<String, String> properties,
String configId, String hostName) {
Objects.requireNonNull(configId);
this.serviceName = serviceName;
this.serviceType = serviceType;
this.ports = ports;
this.properties = properties;
this.configId = configId;
this.hostName = hostName;
}
public String getServiceName() {
return serviceName;
}
public String getConfigId() {
return configId;
}
public String getServiceType() {
return serviceType;
}
public Optional<String> getProperty(String propertyName) {
return Optional.ofNullable(properties.get(propertyName));
}
public Collection<PortInfo> getPorts() {
return ports;
}
public String getHostName() {
return hostName;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ServiceInfo that = (ServiceInfo) o;
if (ports != null ? !ports.equals(that.ports) : that.ports != null) return false;
if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
if (!serviceName.equals(that.serviceName)) return false;
if (!serviceType.equals(that.serviceType)) return false;
if (!configId.equals(that.configId)) return false;
if (!hostName.equals(that.hostName)) return false;
return true;
}
@Override
public int hashCode() {
int result = serviceName.hashCode();
result = 31 * result + serviceType.hashCode();
result = 31 * result + (ports != null ? ports.hashCode() : 0);
result = 31 * result + (properties != null ? properties.hashCode() : 0);
result = 31 * result + configId.hashCode();
result = 31 * result + hostName.hashCode();
return result;
}
}
|