1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.search
;
5 import com
.google
.appengine
.api
.search
.checkers
.Preconditions
;
7 import java
.io
.Serializable
;
8 import java
.util
.Collections
;
9 import java
.util
.Iterator
;
10 import java
.util
.List
;
13 * Represents a result of executing a {@link ListRequest}. The
14 * response contains a list of T.
16 * @param <T> The type of object to be listed from an index
19 public class ListResponse
<T
> implements Iterable
<T
>, Serializable
{
20 private static final long serialVersionUID
= 1189234703739911898L;
22 private final List
<T
> results
;
25 * Creates a {@link ListResponse} by specifying a list of T.
27 * @param results a list of T returned from the index
29 protected ListResponse(List
<T
> results
) {
30 this.results
= Collections
.unmodifiableList(
31 Preconditions
.checkNotNull(results
, "results cannot be null"));
35 public Iterator
<T
> iterator() {
36 return results
.iterator();
40 * @return an unmodifiable list of T from the index
42 public List
<T
> getResults() {
47 public String
toString() {
48 return String
.format("ListResponse(results=%s)", Util
.iterableToString(results
, 0));