Skip to content

Commit

Permalink
add Glob support for plugin tag filtering
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
  • Loading branch information
chrisrueger committed Oct 30, 2024
1 parent 6467e74 commit 7e60cf1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,7 +112,7 @@ public String toString() {
}

/**
* @param tags
* @param tags (globs)
* @return <code>true</code> if any of the given tags is included in the
* current set of tags, otherwise returns <code>false</code>. Also
* if the current set of tags is empty, also <code>true</code> is
Expand All @@ -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));
}

/**
Expand Down

0 comments on commit 7e60cf1

Please sign in to comment.