blob: 733280275405abd84040e4bfc9f2b3171d84b02e (
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
|
package com.yahoo.config.application.api;
import com.yahoo.config.provision.RegionName;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Represents a (global) endpoint in 'deployments.xml'. It contains the name of the
* endpoint (endpointId) and the name of the container cluster that the endpoint
* should point to.
*
* If the endpointId is not set, it will default to the same as the containerId.
*/
public class Endpoint {
private final Optional<String> endpointId;
private final String containerId;
private final Set<RegionName> regions;
public Endpoint(Optional<String> endpointId, String containerId, Set<String> regions) {
this.endpointId = endpointId;
this.containerId = containerId;
this.regions = Set.copyOf(
Objects.requireNonNull(
regions.stream().map(RegionName::from).collect(Collectors.toList()),
"Missing 'regions' parameter"));
}
public String endpointId() {
return endpointId.orElse(containerId);
}
public String containerId() {
return containerId;
}
public Set<RegionName> regions() {
return regions;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Endpoint endpoint = (Endpoint) o;
return Objects.equals(endpointId, endpoint.endpointId) &&
Objects.equals(containerId, endpoint.containerId) &&
Objects.equals(regions, endpoint.regions);
}
@Override
public int hashCode() {
return Objects.hash(endpointId, containerId, regions);
}
}
|