Package graphql.relay
Class SimpleListConnection<T>
- java.lang.Object
-
- graphql.relay.SimpleListConnection<T>
-
- All Implemented Interfaces:
DataFetcher<Connection<T>>
,TrivialDataFetcher<Connection<T>>
@PublicApi public class SimpleListConnection<T> extends java.lang.Object implements DataFetcher<Connection<T>>, TrivialDataFetcher<Connection<T>>
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<T>
data
(package private) static java.lang.String
DUMMY_CURSOR_PREFIX
private java.lang.String
prefix
-
Constructor Summary
Constructors Constructor Description SimpleListConnection(java.util.List<T> data)
SimpleListConnection(java.util.List<T> data, java.lang.String prefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<Edge<T>>
buildEdges()
private java.lang.String
createCursor(int offset)
ConnectionCursor
cursorForObjectInConnection(T object)
find the object's cursor, or null if the object is not in this connection.private Connection<T>
emptyConnection()
Connection<T>
get(DataFetchingEnvironment environment)
This is called by the graphql engine to fetch the value.private int
getOffsetFromCursor(java.lang.String cursor, int defaultValue)
-
-
-
Field Detail
-
DUMMY_CURSOR_PREFIX
static final java.lang.String DUMMY_CURSOR_PREFIX
- See Also:
- Constant Field Values
-
prefix
private final java.lang.String prefix
-
data
private final java.util.List<T> data
-
-
Method Detail
-
get
public Connection<T> get(DataFetchingEnvironment environment)
Description copied from interface:DataFetcher
This is called by the graphql engine to fetch the value. TheDataFetchingEnvironment
is a composite context object that tells you all you need to know about how to fetch a data value in graphql type terms.- Specified by:
get
in interfaceDataFetcher<T>
- Parameters:
environment
- this is the data fetching environment which contains all the context you need to fetch a value- Returns:
- a value of type T. May be wrapped in a
DataFetcherResult
-
emptyConnection
private Connection<T> emptyConnection()
-
cursorForObjectInConnection
public ConnectionCursor cursorForObjectInConnection(T object)
find the object's cursor, or null if the object is not in this connection.- Parameters:
object
- the object in play- Returns:
- a connection cursor
-
getOffsetFromCursor
private int getOffsetFromCursor(java.lang.String cursor, int defaultValue)
-
createCursor
private java.lang.String createCursor(int offset)
-
-