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 {@link Document} to the index. The
14 * response contains a list of {@link OperationResult} indicating success
15 * or not of adding each of the {@link Document Documents}, and a
16 * list of Id of the {@link Document Documents} which are those
17 * given in the request or allocated by the search service to those
18 * {@link Document Documents} which do not have an Id supplied.
20 * @deprecated As of 1.6.5, replaced by {@link AddResponse}.
23 public class AddDocumentsResponse
implements Iterable
<OperationResult
>, Serializable
{
24 private static final long serialVersionUID
= 1189234703739911898L;
26 private final List
<OperationResult
> results
;
27 private final List
<String
> documentIds
;
30 * Creates a {@link AddDocumentsResponse} by specifying a list of
31 * {@link OperationResult} and a list of document ids.
33 * @param results a list of {@link OperationResult} that indicate the
34 * success or not adding each {@link Document}
35 * @param documentIds a list of Id of the {@link Document Documents}
36 * that were requested to be added. The search service may supply Ids for
37 * those Documents where none was supplied
39 AddDocumentsResponse(List
<OperationResult
> results
,
40 List
<String
> documentIds
) {
41 this.results
= Collections
.unmodifiableList(
42 Preconditions
.checkNotNull(results
, "results cannot be null"));
43 this.documentIds
= Collections
.unmodifiableList(
44 Preconditions
.checkNotNull(documentIds
, "documentIds cannot be null"));
48 public Iterator
<OperationResult
> iterator() {
49 return results
.iterator();
53 * @return an unmodifiable list of {@link OperationResult} indicating
54 * whether each {@link Document} was added or not
56 public List
<OperationResult
> getResults() {
61 * @return an unmodifiable list of {@link Document} Ids
64 public List
<String
> getDocumentIds() {
69 public String
toString() {
70 return String
.format("AddDocumentsResponse(results=%s, documentIds=%s)",
71 Util
.iterableToString(results
, 0), Util
.iterableToString(documentIds
, 0));