public abstract class AbstractQueryStepBuilder<S,I,E> extends java.lang.Object implements QueryStepBuilderInternal<S,E>, TraversalTransformer<S,I,E>
| Modifier and Type | Field and Description |
|---|---|
protected TraversalChainElement |
previous |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractQueryStepBuilder(TraversalChainElement previous) |
| Modifier and Type | Method and Description |
|---|---|
QueryStepBuilder<S,E> |
and(QueryStepBuilder<E,?>... subqueries) |
UntypedQueryStepBuilder<S,java.lang.Object> |
back(java.lang.String stepName)
Exits the current traversal state and goes back to a named step, or a named set.
|
long |
count()
Counts the number of elements in the current result, and returns that count.
|
QueryStepBuilder<S,E> |
distinct()
Eliminates all duplicated values from the current result.
|
QueryStepBuilder<S,E> |
except(java.util.Set<?> elementsToExclude)
Removes all elements in the given set from the stream.
|
QueryStepBuilder<S,E> |
except(java.lang.String stepName)
Removes all elements from the given named step from this step.
|
QueryStepBuilder<S,E> |
filter(java.util.function.Predicate<E> predicate)
Applies the given filter predicate to all elements in the current result.
|
<T> UntypedQueryStepBuilder<S,T> |
flatMap(java.util.function.Function<E,java.util.Iterator<T>> function)
Uses the given function to map each element to an iterator of output elements.
|
TraversalChainElement |
getPrevious() |
QueryStepBuilder<S,E> |
limit(long limit)
Limits the number of elements in the result set to the given number.
|
<T> UntypedQueryStepBuilder<S,T> |
map(java.util.function.Function<E,T> function)
Uses the given function to map each element from the current result set to a new element.
|
QueryStepBuilder<S,E> |
named(java.lang.String stepName)
Assigns the given name to this
QueryStepBuilder. |
QueryStepBuilder<S,E> |
not(QueryStepBuilder<E,?> subquery) |
QueryStepBuilder<S,E> |
notNull()
Filters out and discards all
null values from the current result set. |
QueryStepBuilder<S,E> |
or(QueryStepBuilder<E,?>... subqueries) |
QueryStepBuilder<S,E> |
orderBy(java.util.Comparator<E> comparator)
Sorts the current result set by applying the given comparator.
|
void |
setPrevious(TraversalChainElement previous) |
java.util.Iterator<E> |
toIterator()
Creates an iterator over the elements in this query and returns it.
|
java.util.List<E> |
toList()
Calculates the result of this query and returns it as a
List. |
java.util.Set<E> |
toSet()
Calculates the result set of this query and returns it.
|
java.util.stream.Stream<E> |
toStream()
Converts this query into a
Stream. |
UntypedQueryStepBuilder<S,java.lang.Object> |
union(QueryStepBuilder<E,?>... subqueries) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitidentity, transformTraversalprotected TraversalChainElement previous
protected AbstractQueryStepBuilder(TraversalChainElement previous)
public QueryStepBuilder<S,E> filter(java.util.function.Predicate<E> predicate)
QueryStepBuilderfilter in interface QueryStepBuilder<S,E>predicate - The predicate to apply. Must not be null. All elements for which the predicate function
returns false will be filtered out and discarded.null.public QueryStepBuilder<S,E> limit(long limit)
QueryStepBuilder
Please note that the order of elements is in general arbitrary. Therefore, usually a QueryStepBuilder.limit(long) is
preceded by a QueryStepBuilder.orderBy(Comparator).
limit in interface QueryStepBuilder<S,E>limit - The limit to apply. Must not be negative.null.public QueryStepBuilder<S,E> orderBy(java.util.Comparator<E> comparator)
QueryStepBuilder
This method requires full resolution of all elements and is therefore non-lazy.
orderBy in interface QueryStepBuilder<S,E>comparator - The comparator to use. Must not be null.null.public QueryStepBuilder<S,E> distinct()
QueryStepBuilder
This method is lazy, but requires to keep track of the "already encountered" elements in a set. Therefore, RAM consumption on this method may be high if it is applied on very large result sets.
distinct in interface QueryStepBuilder<S,E>null.public <T> UntypedQueryStepBuilder<S,T> map(java.util.function.Function<E,T> function)
QueryStepBuildermap in interface QueryStepBuilder<S,E>function - The mapping function to apply. Must not be null. Should be idempotent and side-effect
free.null.public <T> UntypedQueryStepBuilder<S,T> flatMap(java.util.function.Function<E,java.util.Iterator<T>> function)
QueryStepBuilderflatMap in interface QueryStepBuilder<S,E>function - The map function to apply. Must not be null. Should be idempotent and side-effect free.null.public QueryStepBuilder<S,E> notNull()
QueryStepBuildernull values from the current result set.
This is the same as:
query.filter(element -> element != null)
notNull in interface QueryStepBuilder<S,E>null.QueryStepBuilder.filter(Predicate)public QueryStepBuilder<S,E> named(java.lang.String stepName)
QueryStepBuilderQueryStepBuilder.
Note that only the step is named. When coming back to this step, the query result may be different than it was when it was first reached, depending on the traversal.
named in interface QueryStepBuilder<S,E>stepName - The name of the step. Must not be null. Must be unique within the query.null.QueryStepBuilder.back(String)public UntypedQueryStepBuilder<S,java.lang.Object> back(java.lang.String stepName)
QueryStepBuilderback in interface QueryStepBuilder<S,E>stepName - The name of the step to go back to. Must not be null, must refer to a named step.null.QueryStepBuilder.named(String)public QueryStepBuilder<S,E> except(java.lang.String stepName)
QueryStepBuilderexcept in interface QueryStepBuilder<S,E>stepName - The name of the step. Must not be null, must refer to a named step.null.public QueryStepBuilder<S,E> except(java.util.Set<?> elementsToExclude)
QueryStepBuilderexcept in interface QueryStepBuilder<S,E>elementsToExclude - The elements to remove. Must not be null.null.public UntypedQueryStepBuilder<S,java.lang.Object> union(QueryStepBuilder<E,?>... subqueries)
union in interface QueryStepBuilder<S,E>public QueryStepBuilder<S,E> and(QueryStepBuilder<E,?>... subqueries)
and in interface QueryStepBuilder<S,E>public QueryStepBuilder<S,E> or(QueryStepBuilder<E,?>... subqueries)
or in interface QueryStepBuilder<S,E>public QueryStepBuilder<S,E> not(QueryStepBuilder<E,?> subquery)
not in interface QueryStepBuilder<S,E>public java.util.Set<E> toSet()
QueryStepBuilder
Please note that iterating over the result set via QueryStepBuilder.toIterator() is in general faster
and consumes less RAM than first converting the result into a set.
toSet in interface QueryStepBuilder<S,E>null. May be empty.public java.util.List<E> toList()
QueryStepBuilderList.
Please note that iterating over the result via QueryStepBuilder.toIterator() is in general faster and
consumes less RAM than first converting the result into a list.
toList in interface QueryStepBuilder<S,E>null. May be empty.public java.util.stream.Stream<E> toStream()
QueryStepBuilderStream.toStream in interface QueryStepBuilder<S,E>public long count()
QueryStepBuildercount in interface QueryStepBuilder<S,E>public java.util.Iterator<E> toIterator()
QueryStepBuildertoIterator in interface QueryStepBuilder<S,E>null.public TraversalChainElement getPrevious()
getPrevious in interface QueryStepBuilderInternal<S,E>public void setPrevious(TraversalChainElement previous)
setPrevious in interface QueryStepBuilderInternal<S,E>