Skip to content

Commit

Permalink
Allow iteration over MultiGetRequest#Item instances
Browse files Browse the repository at this point in the history
Closes #3061
  • Loading branch information
s1monw committed Mar 20, 2014
1 parent ecdcc2d commit adfa82b
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -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;
Expand All @@ -39,9 +40,10 @@

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.
Expand Down Expand Up @@ -404,6 +406,11 @@ public MultiGetRequest add(@Nullable String defaultIndex, @Nullable String defau
return this;
}

@Override
public Iterator<Item> iterator() {
return Iterators.unmodifiableIterator(items.iterator());
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
Expand Down

0 comments on commit adfa82b

Please sign in to comment.