use of org.locationtech.geogig.api.plumbing.ForEachRef in project GeoGig by boundlessgeo.
the class ShowRef method runInternal.
@Override
public void runInternal(GeogigCLI cli) throws IOException {
ConsoleReader console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
ForEachRef op = geogig.command(ForEachRef.class);
Predicate<Ref> filter = new Predicate<Ref>() {
@Override
public boolean apply(Ref ref) {
String name = ref.getName();
if (!name.startsWith(Ref.REFS_PREFIX)) {
return false;
}
boolean match = patterns.isEmpty() ? true : false;
for (String pattern : patterns) {
if (Strings.isNullOrEmpty(pattern)) {
match = true;
} else if (name.endsWith("/" + pattern)) {
match = true;
break;
}
}
return match;
}
};
op.setFilter(filter);
ImmutableSet<Ref> refs = op.call();
for (Ref ref : refs) {
console.println(ref.getObjectId() + " " + ref.getName());
}
}
Aggregations