From 419001282a9ab11c7c0769156a37e72852dd008b Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Thu, 29 Feb 2024 00:14:26 -0500 Subject: [PATCH] refactor --- .../java/io/cryostat/graphql/RootNode.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/cryostat/graphql/RootNode.java b/src/main/java/io/cryostat/graphql/RootNode.java index 8dfa12acd..c8b687d5c 100644 --- a/src/main/java/io/cryostat/graphql/RootNode.java +++ b/src/main/java/io/cryostat/graphql/RootNode.java @@ -78,29 +78,23 @@ public boolean test(DiscoveryNode t) { n -> name == null || Objects.equals(name, n.name); Predicate matchesNames = n -> names == null || names.contains(n.name); Predicate 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 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)