Allow iteration over MultiGetRequest#Item instances

Closes #3061
This commit is contained in:
Simon Willnauer 2014-03-20 10:24:12 +01:00
parent ecdcc2df92
commit adfa82b2ed
1 changed files with 8 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.action.get;
import com.google.common.collect.Iterators;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.ActionRequest;
@ -39,9 +40,10 @@ import org.elasticsearch.search.fetch.source.FetchSourceContext;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class MultiGetRequest extends ActionRequest<MultiGetRequest> {
public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements Iterable<MultiGetRequest.Item> {
/**
* A single get item.
@ -404,6 +406,11 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> {
return this;
}
@Override
public Iterator<Item> iterator() {
return Iterators.unmodifiableIterator(items.iterator());
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);