blob: af1abff142bebc146951bf97876df4bd00d3d4f1 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.routing;
import com.yahoo.collections.AbstractFilteringList;
import com.yahoo.config.provision.zone.AuthMethod;
import com.yahoo.vespa.hosted.controller.application.EndpointId;
import com.yahoo.vespa.hosted.controller.application.GeneratedEndpoint;
import java.util.Collection;
import java.util.List;
/**
* An immutable, filterable list of {@link GeneratedEndpoint}.
*
* @author mpolden
*/
public class GeneratedEndpointList extends AbstractFilteringList<GeneratedEndpoint, GeneratedEndpointList> {
public static final GeneratedEndpointList EMPTY = new GeneratedEndpointList(List.of(), false);
private GeneratedEndpointList(Collection<? extends GeneratedEndpoint> items, boolean negate) {
super(items, negate, GeneratedEndpointList::new);
}
/** Returns the subset of endpoints which are generated for given endpoint ID */
public GeneratedEndpointList declared(EndpointId endpoint) {
return matching(e -> e.endpoint().isPresent() && e.endpoint().get().equals(endpoint));
}
/** Returns the subset of endpoints which are generated for endpoints declared in {@link com.yahoo.config.application.api.DeploymentSpec} */
public GeneratedEndpointList declared() {
return matching(GeneratedEndpoint::declared);
}
/** Returns the subset endpoints which are generated for clusters declared in {@link com.yahoo.vespa.hosted.controller.application.pkg.BasicServicesXml} */
public GeneratedEndpointList cluster() {
return not().declared();
}
/** Returns the subset of endpoints matching given auth method */
public GeneratedEndpointList authMethod(AuthMethod authMethod) {
return matching(ge -> ge.authMethod() == authMethod);
}
public static GeneratedEndpointList of(GeneratedEndpoint... generatedEndpoint) {
return copyOf(List.of(generatedEndpoint));
}
public static GeneratedEndpointList copyOf(Collection<GeneratedEndpoint> generatedEndpoints) {
return generatedEndpoints.isEmpty() ? EMPTY : new GeneratedEndpointList(generatedEndpoints, false);
}
@Override
public String toString() {
return asList().toString();
}
}
|