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 putting a list of objects (documents or queries)
14 * into an index. The response contains a list of {@link OperationResult}
15 * indicating success or not of putting each of the objects into the index,
16 * and a list of Id of the objects which are those given in the request or
17 * allocated by the search service to those objects which do not have an
21 public class PutResponse
implements Iterable
<OperationResult
>, Serializable
{
22 private static final long serialVersionUID
= 3063892804095727768L;
24 private final List
<OperationResult
> results
;
25 private final List
<String
> ids
;
28 * Creates a {@link PutResponse} by specifying a list of
29 * {@link OperationResult} and a list of document or query ids.
31 * @param results a list of {@link OperationResult} that indicate the
32 * success or not putting each object into the index
33 * @param ids a list of Id of objects that were requested to be
34 * put into the index. The search service may supply Ids for those objects
35 * where none was supplied
37 protected PutResponse(List
<OperationResult
> results
, List
<String
> ids
) {
38 this.results
= Collections
.unmodifiableList(
39 Preconditions
.checkNotNull(results
, "results cannot be null"));
40 this.ids
= Collections
.unmodifiableList(
41 Preconditions
.checkNotNull(ids
, "ids cannot be null"));
45 public Iterator
<OperationResult
> iterator() {
46 return results
.iterator();
50 * @return an unmodifiable list of {@link OperationResult} indicating
51 * whether each {@link Document} was put or not
53 public List
<OperationResult
> getResults() {
58 * @return an unmodifiable list of Ids
60 public List
<String
> getIds() {
65 public String
toString() {
66 return String
.format("PutResponse(results=%s, ids=%s)",
67 Util
.iterableToString(getResults(), 0), Util
.iterableToString(getIds(), 0));