1
2 package hoplugins.transfers.utils;
3
4 import hoplugins.Commons;
5
6 import plugins.ISpieler;
7
8 import java.util.Iterator;
9 import java.util.List;
10
11
12 /***
13 * Utility to retrieve a player by an id, even if it is an old-player.
14 *
15 * @author <a href=mailto:nethyperon@users.sourceforge.net>Boy van der Werf</a>
16 */
17 public final class PlayerRetriever {
18
19
20 /***
21 * Private default constuctor to prevent class instantiation.
22 */
23 private PlayerRetriever() {
24 }
25
26
27
28 /***
29 * Retrieve a player by his ID.
30 *
31 * @param id Player ID
32 *
33 * @return ISpieler interface representing the foun player or <code>null</code> if no player
34 * could be found.
35 */
36 public static ISpieler getPlayer(int id) {
37 final ISpieler player = Commons.getModel().getSpieler(id);
38
39 if (player == null) {
40 final List oldPlayers = Commons.getModel().getAllOldSpieler();
41
42 for (final Iterator iter = oldPlayers.iterator(); iter.hasNext();) {
43 final ISpieler oldPlayer = (ISpieler) iter.next();
44
45 if (oldPlayer.getSpielerID() == id) {
46 return oldPlayer;
47 }
48 }
49
50 return null;
51 } else {
52 return player;
53 }
54 }
55 }