Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for repository tags #6116

Merged
merged 13 commits into from
Jun 21, 2024
Prev Previous commit
Next Next commit
use Set
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
  • Loading branch information
chrisrueger committed May 8, 2024
commit ea7740d6139c4cc88d55ecd07ccd958cf1d32e1c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class BaseRepository implements Repository, Tagged {
PromiseFactory.inlineExecutor());

private static final String DEFAULT_TAG = "all";
private static final List<String> DEFAULT_TAGS = List.of(DEFAULT_TAG);
private static final Set<String> DEFAULT_TAGS = Set.of(DEFAULT_TAG);

static {
Requirement requireAll = ResourceUtils.createWildcardRequirement();
Expand Down Expand Up @@ -249,7 +249,7 @@ public RequirementBuilder addAttribute(String name, Object value) {
}

@Override
public List<String> getTags() {
public Set<String> getTags() {
return DEFAULT_TAGS;
}
}
12 changes: 7 additions & 5 deletions biz.aQute.bndlib/src/aQute/bnd/service/Tagged.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package aQute.bnd.service;

import java.util.Arrays;
import java.util.List;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
* Allows to add tags to implementing classes. Originally intended for tagging
Expand All @@ -12,16 +14,16 @@ public interface Tagged {
/**
* @return a non-null list of tags.
*/
List<String> getTags();
Set<String> getTags();

static List<String> toTags(String csvTags) {
static Set<String> toTags(String csvTags) {
if (csvTags == null || csvTags.isBlank()) {
return List.of("all"); // default
return Set.of("all"); // default
}

return Arrays.stream(csvTags.split(","))
.map(String::trim)
.toList();
.collect(Collectors.toCollection(LinkedHashSet::new));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ public boolean isRemote() {
}

@Override
public List<String> getTags() {
public Set<String> getTags() {
return Tagged.toTags(configuration.tags());
}
}