/** * If the current position in the traversal defines any select candidates, the new context will have its source path * composed by appending the select candidates to the current source path. * * @return a context builder with the modified source path */ Builder<BE, E> proceed() { return new Builder<>(this, hop(), Query.filter(), entityClass); }
/** * The new context will have the source path composed by appending current select candidates to the current source * path. The new context will have select candidates such that it will select the relationships in given direction * stemming from the entities on the new source path. * * @param direction the direction of the relationships to look for * @return a context builder with the modified source path, select candidates and type */ Builder<BE, Relationship> proceedToRelationships(Relationships.Direction direction) { return new Builder<>(this, hop(), Query.filter(), Relationship.class) .hop(new SwitchElementType(direction, false)); }
/** * Virtually identical to {@link #proceedTo(Relationships.WellKnown, Class)} only follows the relationship in the * opposite direction. * * @param over the relationship to retreat over (i.e. if the current position is the target of the * relationship, the sought after entity type needs to be the source of the relationship). * @param entityType the type of the entities to retreat to * @param <T> the type of the "target" entities * @return a context builder with the modified source path, select candidates and type */ <T extends Entity<?, ?>> Builder<BE, T> retreatTo(Relationships.WellKnown over, Class<T> entityType) { return new Builder<>(this, hop(), Query.filter(), entityType).hop(Related.asTargetBy(over), type(entityType)); }
/** * The new context will have the source path composed by appending current select candidates to the current source * path and its select candidates will filter for entities related by the provided relationship to the new sources * and will have the provided type. * * @param over the relationship with which the select candidates will be related to the entities on the source * path * @param entityType the type of the entities related to the entities on the source path * @param <T> the type of the "target" entities * @return a context builder with the modified source path, select candidates and type */ <T extends Entity<?, ?>> Builder<BE, T> proceedTo(Relationships.WellKnown over, Class<T> entityType) { return new Builder<>(this, hop(), Query.filter(), entityType).hop(Related.by(over), type(entityType)); }
/** * An opposite of {@link #proceedToRelationships(Relationships.Direction)}. * * @param direction the direction in which to "leave" the relationships * @param entityType the type of entities to "hop to" * @param <T> the type of entities to "hop to" * @return a context builder with the modified source path, select candidates and type */ <T extends Entity<?, ?>> Builder<BE, T> proceedFromRelationshipsTo(Relationships.Direction direction, Class<T> entityType) { return new Builder<>(this, hop(), Query.filter(), entityType) .hop(new SwitchElementType(direction, true)).where(type(entityType)); }