Version 1.7.4
[gae.git] / java / src / main / com / google / appengine / api / search / AddResponse.java
blob2be0bc685e5db78ef00357c1de927ee7fc3e7f8c
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 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.
21 @Deprecated
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;
28 /**
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
36 * none was supplied
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"));
45 @Override
46 public Iterator<OperationResult> iterator() {
47 return results.iterator();
50 /**
51 * @return an unmodifiable list of {@link OperationResult} indicating
52 * whether each {@link Document} was added or not
54 public List<OperationResult> getResults() {
55 return results;
58 /**
59 * @return an unmodifiable list of Ids
61 public List<String> getIds() {
62 return ids;
65 @Override
66 public String toString() {
67 return String.format("AddResponse(results=%s, ids=%s)",
68 Util.iterableToString(getResults(), 0), Util.iterableToString(getIds(), 0));