From 7e60cf1c47a2ec894a93da3288eec9ebb66beab6 Mon Sep 17 00:00:00 2001 From: Christoph Rueger Date: Wed, 30 Oct 2024 12:38:44 +0100 Subject: [PATCH] add Glob support for plugin tag filtering Signed-off-by: Christoph Rueger --- .../src/aQute/bnd/service/tags/Tags.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java index 367fb6581a..24a4e7c4c1 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java +++ b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java @@ -11,6 +11,8 @@ import java.util.TreeSet; import java.util.stream.Collectors; +import aQute.libg.glob.Glob; + /** * A set of tags. A tag is a string-token which can be attached to an entity for * categorization and filtering. Typically these entities then implement the @@ -110,7 +112,7 @@ public String toString() { } /** - * @param tags + * @param tags (globs) * @return true if any of the given tags is included in the * current set of tags, otherwise returns false. Also * if the current set of tags is empty, also true is @@ -126,13 +128,19 @@ public boolean includesAny(String... tags) { return true; } - for (String tag : tags) { - if (contains(tag)) { + for (String tagGlob : tags) { + if (matchesAny(new Glob(tagGlob))) { return true; } } return false; + + } + + private boolean matchesAny(Glob glob) { + return internalSet.stream() + .anyMatch(s -> glob.matches(s)); } /**