Search in sources :

Example 1 with ForEachRef

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());
    }
}
Also used : Ref(org.locationtech.geogig.api.Ref) ForEachRef(org.locationtech.geogig.api.plumbing.ForEachRef) ConsoleReader(jline.console.ConsoleReader) ForEachRef(org.locationtech.geogig.api.plumbing.ForEachRef) GeoGIG(org.locationtech.geogig.api.GeoGIG) Predicate(com.google.common.base.Predicate)

Aggregations

Predicate (com.google.common.base.Predicate)1 ConsoleReader (jline.console.ConsoleReader)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 Ref (org.locationtech.geogig.api.Ref)1 ForEachRef (org.locationtech.geogig.api.plumbing.ForEachRef)1