2 * jFCPlib-high-level-client - PeerListResult.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.fcp.highlevel;
22 import java.util.ArrayList;
23 import java.util.Iterator;
24 import java.util.List;
26 import net.pterodactylus.fcp.Peer;
29 * The result of a {@link HighLevelClient#getPeers()} operation.
31 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
33 public class PeerListResult extends HighLevelResult implements Iterable<Peer> {
35 /** The list of peers. */
36 private final List<Peer> peers = new ArrayList<Peer>();
39 * Package-private constructor.
42 * The identifier of the request
44 PeerListResult(String identifier) {
49 * Adds a peer to the list.
54 void addPeer(Peer peer) {
61 public Iterator<Peer> iterator() {
62 return peers.iterator();
66 * Returns the peer at the given index.
69 * The index of the peer
71 * @see java.util.List#get(int)
73 public Peer get(int index) {
74 return peers.get(index);
78 * Returns the size of the peer list.
80 * @return The size of the peer list
81 * @see java.util.List#size()