Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Feb 29, 2024
1 parent e6c3388 commit 4190012
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/main/java/io/cryostat/graphql/RootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,23 @@ public boolean test(DiscoveryNode t) {
n -> name == null || Objects.equals(name, n.name);
Predicate<DiscoveryNode> matchesNames = n -> names == null || names.contains(n.name);
Predicate<DiscoveryNode> matchesLabels =
n -> {
if (labels == null) {
return true;
}
var allMatch = true;
for (var l : labels) {
allMatch &= LabelSelectorMatcher.parse(l).test(n.labels);
}
return allMatch;
};
n ->
labels == null
|| labels.stream()
.allMatch(
label ->
LabelSelectorMatcher.parse(label)
.test(n.labels));
Predicate<DiscoveryNode> matchesAnnotations =
n -> {
if (annotations == null) {
return true;
}
var allMatch = true;
for (var l : annotations) {
allMatch &=
LabelSelectorMatcher.parse(l)
.test(n.target.annotations.merged());
}
return allMatch;
};
n ->
annotations == null
|| annotations.stream()
.allMatch(
annotation ->
LabelSelectorMatcher.parse(annotation)
.test(
n.target.annotations
.merged()));

return matchesId
.and(matchesName)
Expand Down

0 comments on commit 4190012

Please sign in to comment.