/** * Proceeds the traversal to the next entities taking into account what parents the next entities should have. * * @param nextEntityType the type of the entities the new context will target * @param parentsType the type of the enum containing the possible parent types * @param currentParent the parent type representing the current position in the traversal * @param parents the parents to proceed to target entities over * @param hopBuilder the producer function that will convert the parent into a filter path to apply to the * traversal * @param <T> the type of the next entity * @param <P> the type of the enum of the possible parents of the target entity * @return a new traversal context */ <T extends Entity<?, ?>, P extends Enum<P> & Parents> TraversalContext<BE, T> proceedWithParents(Class<T> nextEntityType, Class<P> parentsType, P currentParent, P[] parents, BiConsumer<P, Query.SymmetricExtender> hopBuilder) { EnumSet<P> ps = ParentsUtil.convert(parentsType, currentParent, parents); TraversalContext.Builder<BE, E> bld = proceed(); for (P p : ps) { Query.Builder qb = bld.rawQueryBuilder(); qb = qb.branch(); Query.SymmetricExtender extender = qb.symmetricExtender(); hopBuilder.accept(p, extender); qb.done(); } return bld.getting(nextEntityType); }
/** * Builds the <b>whole</b> tree regardless of where in the tree the current builder "operates". * * @return the fully built tree */ public Query build() { Query.Builder root = this; while (true) { if (root.parent == null) { break; } root = root.parent; } root.done(); return root.tree; } }
public Builder with(Query other, Function<Filter, QueryFragment> converter) { with(converter, other.fragments); for (Query sub : other.getSubTrees()) { branch().with(sub, converter).done(); } return this; }
public Builder with(Query other) { with(other.fragments); for (Query sub : other.getSubTrees()) { branch().with(sub).done(); } return this; }