Class Cursor
java.lang.Object
com.helixframework.pagination.cursor.Cursor
- All Implemented Interfaces:
Serializable,Iterable<Criterion>
Bidirectional pagination cursor that supports multiple key and sorting criteria.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe Builder class is a utility class for creating instances of the Cursor class.static enumDirection of a cursor used for pagination. -
Method Summary
Modifier and TypeMethodDescriptionstatic Cursor.Builderbuilder()Returns a builder forCursor.static Cursor.BuilderReturns a builder forCursorconfigured with the previous cursor's criteria.booleanReturns an unmodifiable map of criteria stored in the Cursor.getCriterion(String name) Retrieves a criterion with the given name.Optional<com.helixframework.pagination.sort.SortOrder>getCriterionSortOrder(String name) Retrieves the sort order associated of the criterion with the given name.getCriterionValue(String name) Retrieves the value of the criterion with the given name.Returns the direction of the cursor.inthashCode()iterator()keySet()Returns a set of keys representing the criteria.Retrieves the next cursor given the previous cursor, limit, result type, and results list.next(Cursor prevCursor, int limit, Class<T> resultType, List<T> results, Function<T, List<Criterion>> fn) Retrieves the next cursor given the previous cursor, limit, results, function, and class.static CursorParses a token and returns aCursor.longsize()Returns the number of criteria.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
builder
Returns a builder forCursor.- Returns:
- builder
-
builder
Returns a builder forCursorconfigured with the previous cursor's criteria.- Parameters:
prevCursor- previous cursor- Returns:
- builder
-
parse
Parses a token and returns aCursor.- Parameters:
token- the token to parse- Returns:
- the parsed Cursor object
- Throws:
IllegalArgumentException- if there is an error parsing the token
-
next
public static <T> Optional<Cursor> next(Cursor prevCursor, int limit, Class<T> resultType, List<T> results) Retrieves the next cursor given the previous cursor, limit, result type, and results list.- Type Parameters:
T- The type of the results- Parameters:
prevCursor- The previous cursorlimit- The limit of results per pageresultType- The type of the resultresults- The list of results- Returns:
- An Optional wrapping the next cursor if it exists, otherwise Optional.empty()
-
next
public static <T> Optional<Cursor> next(Cursor prevCursor, int limit, Class<T> resultType, List<T> results, Function<T, List<Criterion>> fn) Retrieves the next cursor given the previous cursor, limit, results, function, and class.- Type Parameters:
T- The type of the results- Parameters:
prevCursor- The previous cursorlimit- The limit of results per pageresultType- The type of the resultresults- The list of resultsfn- The function to generate the next cursor- Returns:
- An Optional wrapping the next cursor if it exists, otherwise Optional.empty()
-
getCriteria
Returns an unmodifiable map of criteria stored in the Cursor.- Returns:
- an unmodifiable map of criteria
-
getCriterion
Retrieves a criterion with the given name.- Parameters:
name- the name of the criterion to retrieve- Returns:
- an Optional wrapping the criterion if it exists, otherwise Optional.empty()
-
getCriterionValue
Retrieves the value of the criterion with the given name.- Parameters:
name- the name of the criterion to retrieve the value for- Returns:
- an Optional wrapping the criterion value if the criterion exists, otherwise Optional.empty()
-
getCriterionSortOrder
Retrieves the sort order associated of the criterion with the given name.- Parameters:
name- the name of the criterion- Returns:
- an Optional object wrapping the SortOrder if the criterion exists, otherwise Optional.empty()
-
keySet
Returns a set of keys representing the criteria.- Returns:
- a set of keys representing the criteria
-
size
public long size()Returns the number of criteria.- Returns:
- the size of the criteria
-
getDirection
Returns the direction of the cursor.- Returns:
- the direction of the cursor
-
iterator
-
toString
-
equals
-
hashCode
public int hashCode()
-