Class Subrange<P>
java.lang.Object
org.springframework.graphql.data.pagination.Subrange<P>
- Type Parameters:
P
- the type of position in the entire collection
- Direct Known Subclasses:
ScrollSubrange
Container for parameters that limit result elements to a subrange including a
relative position, number of elements, and direction.
- Since:
- 1.2.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncount()
The number of elements in the subrange based on the "first" and "last" arguments from the GraphQL Cursor connection spec.boolean
forward()
Whether the subrange is forward or backward from ths position, depending on whether the argument sent "first" or "last".position()
The position of the result element the subrange is relative to.
-
Constructor Details
-
Subrange
Constructor with the relative position, count, and direction.- Parameters:
position
- the position in the entire collectioncount
- the number of elements in the subrangeforward
- whether the subrange is forward or backward from ths position
-
-
Method Details
-
position
The position of the result element the subrange is relative to. This is decoded from the "before" or "after" input arguments from the GraphQL Cursor connection spec viaCursorStrategy
. -
count
The number of elements in the subrange based on the "first" and "last" arguments from the GraphQL Cursor connection spec. -
forward
public boolean forward()Whether the subrange is forward or backward from ths position, depending on whether the argument sent "first" or "last".Note: The direction may not always match the original value. For backward pagination, for example, an offset cursor could be adjusted down by the count of elements, switching backward to forward.
-