+public class PeerListResult extends HighLevelResult implements Iterable<Peer> {
+
+ /** The list of peers. */
+ private final List<Peer> peers = new ArrayList<Peer>();
+
+ /**
+ * Package-private constructor.
+ *
+ * @param identifier
+ * The identifier of the request
+ */
+ PeerListResult(String identifier) {
+ super(identifier);
+ }
+
+ /**
+ * Adds a peer to the list.
+ *
+ * @param peer
+ * The peer to add
+ */
+ void addPeer(Peer peer) {
+ peers.add(peer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Iterator<Peer> iterator() {
+ return peers.iterator();
+ }
+
+ /**
+ * Returns the peer at the given index.
+ *
+ * @param index
+ * The index of the peer
+ * @return The peer
+ * @see java.util.List#get(int)
+ */
+ public Peer get(int index) {
+ return peers.get(index);
+ }
+
+ /**
+ * Returns the size of the peer list.
+ *
+ * @return The size of the peer list
+ * @see java.util.List#size()
+ */
+ public int size() {
+ return peers.size();
+ }