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 adding a list of objects (documents or queries)
14 * to an index. The response contains a list of {@link OperationResult}
15 * indicating success or not of adding each of the objects, and a list
16 * of Id of the objects which are those given in the request or allocated
17 * by the search service to those objects which do not have an Id supplied.
19 * @deprecated as of 1.7.3. Use {@link PutResponse} instead.
22 public class AddResponse
implements Iterable
<OperationResult
>, Serializable
{
23 private static final long serialVersionUID
= 1189234703739911898L;
25 private final List
<OperationResult
> results
;
26 private final List
<String
> ids
;
29 * Creates a {@link AddResponse} by specifying a list of
30 * {@link OperationResult} and a list of document or query ids.
32 * @param results a list of {@link OperationResult} that indicate the
33 * success or not adding each object
34 * @param ids a list of Id of objects that were requested to be
35 * added. The search service may supply Ids for those objects where
38 protected AddResponse(List
<OperationResult
> results
, List
<String
> ids
) {
39 this.results
= Collections
.unmodifiableList(
40 Preconditions
.checkNotNull(results
, "results cannot be null"));
41 this.ids
= Collections
.unmodifiableList(
42 Preconditions
.checkNotNull(ids
, "ids cannot be null"));
46 public Iterator
<OperationResult
> iterator() {
47 return results
.iterator();
51 * @return an unmodifiable list of {@link OperationResult} indicating
52 * whether each {@link Document} was added or not
54 public List
<OperationResult
> getResults() {
59 * @return an unmodifiable list of Ids
61 public List
<String
> getIds() {
66 public String
toString() {
67 return String
.format("AddResponse(results=%s, ids=%s)",
68 Util
.iterableToString(getResults(), 0), Util
.iterableToString(getIds(), 0));