Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / search / ListResponse.java
blob044d208b7a7108f91e7d03eebe0b35d03a30ee65
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;
12 /**
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;
24 /**
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"));
34 @Override
35 public Iterator<T> iterator() {
36 return results.iterator();
39 /**
40 * @return an unmodifiable list of T from the index
42 public List<T> getResults() {
43 return results;
46 @Override
47 public String toString() {
48 return String.format("ListResponse(results=%s)", Util.iterableToString(results, 0));