public class CollectionResponse<T>
extends java.lang.Object
Collection response to be returned by an endpoint implementation method that wants to support
pagination (and other metadata about returned collection in the future). Endpoint
implementation method would do something like this to use it:
public CollectionResponse<Greeting> list(@Named("pageToken") String pageToken) {
List<Greeting> greetings = new ArrayList<Greeting>();
// use pageToken to fill greetings with next page of items
return CollectionResponse.<Greeting>builder()
.setItems(greetings)
.setNextPageToken("newPageToken")
.build();
}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-28 UTC."],[[["\u003cp\u003e\u003ccode\u003eCollectionResponse<T>\u003c/code\u003e is a class designed to handle paginated responses from an endpoint, facilitating the management of large datasets.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuilder()\u003c/code\u003e method allows for the creation of a \u003ccode\u003eCollectionResponse\u003c/code\u003e object using a builder pattern, offering a structured way to set its properties.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetItems()\u003c/code\u003e method returns the current collection of items (\u003ccode\u003ejava.util.Collection<T>\u003c/code\u003e) included in the response.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetNextPageToken()\u003c/code\u003e method provides a string token (\u003ccode\u003ejava.lang.String\u003c/code\u003e) to retrieve the subsequent page of results, enabling seamless pagination.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eCollectionResponse\u003c/code\u003e class includes a protected constructor that takes a collection of items and a next page token as arguments, used to instantiate an object.\u003c/p\u003e\n"]]],[],null,["# CollectionResponse\n\ncom.google.api.server.spi.response\n\nClass CollectionResponse\\\u003cT\\\u003e\n-----------------------------\n\n- java.lang.Object\n-\n - com.google.api.server.spi.response.CollectionResponse\\\u003cT\\\u003e\n\n-\n\n *** ** * ** ***\n\n \u003cbr /\u003e\n\n ```\n public class CollectionResponse\u003cT\u003e\n extends java.lang.Object\n ``` \n Collection response to be returned by an endpoint implementation method that wants to support pagination (and other metadata about returned collection in the future). Endpoint implementation method would do something like this to use it:\n\n\n `\n public CollectionResponse\u003cGreeting\u003e list(@Named(\"pageToken\") String pageToken) {\n List\u003cGreeting\u003e greetings = new ArrayList\u003cGreeting\u003e();\n // use pageToken to fill greetings with next page of items\n return CollectionResponse.\u003cGreeting\u003ebuilder()\n .setItems(greetings)\n .setNextPageToken(\"newPageToken\")\n .build();\n }\n` \n-\n -\n\n ### Nested Class Summary\n\n \u003c!-- --\u003e\n\n -\n\n ### Constructor Summary\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Summary\n\n -\n\n ### Methods inherited from class java.lang.Object\n\n`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait` \n-\n -\n\n ### Constructor Detail\n\n\n -\n\n #### CollectionResponse\n\n ```\n protected CollectionResponse(java.util.Collection\u003cT\u003e items,\n java.lang.String nextPageToken)\n ```\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Detail\n\n\n -\n\n #### builder\n\n ```\n public static \u003cT\u003e CollectionResponse.Builder\u003cT\u003e builder()\n ```\n\n\n -\n\n #### getNextPageToken\n\n ```\n public java.lang.String getNextPageToken()\n ```\n\n\n -\n\n #### getItems\n\n ```\n public java.util.Collection\u003cT\u003e getItems()\n ```"]]