public Builder filter() { queryFragmentSupplier = FilterFragment::from; converter = FilterFragment::new; if (isFilter != null && !isFilter && this.fragments.isEmpty()) { with(NoopFilter.INSTANCE); } isFilter = true; return this; }
public Builder path() { queryFragmentSupplier = PathFragment::from; converter = PathFragment::new; if (isFilter != null && isFilter && !this.fragments.isEmpty()) { with(NoopFilter.INSTANCE); } isFilter = false; return this; }
public Builder with(Filter... filters) { with(converter, queryFragmentSupplier.apply(filters)); return this; }
/** * Appends the filters as query fragments determined by the last call to {@link #filter()} or {@link #path()}. * * <p>The filters is an array of arrays representing a new set of branches to be created at all the leaves of * the current query tree. * * @param filters the filters to append to the leaves of the query tree * @return this instance */ public SymmetricExtender with(Filter[][] filters) { onLeaves(this.filters, (builder) -> { for (Filter[] fs : filters) { builder.branch().with(queryFragmentSupplier.apply(fs)); } }); return this; }
/** * Appends the filters as query fragments determined by the last call to {@link #filter()} or {@link #path()}. * * @param filters the filters to append to the leaves of the query tree * @return this instance */ public SymmetricExtender with(Filter... filters) { onLeaves(this.filters, (t) -> t.with(queryFragmentSupplier.apply(filters))); return this; }
/** * Appends the provided query to the leaves of the current query tree, leaving the type of its fragments as they * originally were. * * @param other the query to append * @return this instance */ public SymmetricExtender withExact(Query other) { onLeaves(this.filters, (builder) -> builder.with(other)); return this; }
/** * Appends the provided query to the leaves of the current query tree, converting all its fragments to the * current fragment type (determined by the last call to {@link #filter()} or {@link #path()}). * * @param other the query to append * @return this instance */ public SymmetricExtender with(Query other) { onLeaves(this.filters, (builder) -> builder.with(other, converter)); return this; }