More code hygiene. Need to do some fiddling to make dispatchers not generate

generics warnings when calling methods with generic types.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@698 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-08-01 14:40:54 +00:00
parent 7708bc96a6
commit bb0d6c5ba4
62 changed files with 292 additions and 274 deletions
@@ -30,6 +30,7 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.swing.event.MouseInputAdapter;
@@ -620,10 +621,10 @@ public abstract class CardPanel extends VirtualMediaPanel
* Returns the first card sprite in the specified list that represents the specified card, or
* null if there is no such sprite in the list.
*/
protected CardSprite getCardSprite (ArrayList list, Card card)
protected CardSprite getCardSprite (List<CardSprite> list, Card card)
{
for (int i = 0; i < list.size(); i++) {
CardSprite cs = (CardSprite)list.get(i);
CardSprite cs = list.get(i);
if (card.equals(cs.getCard())) {
return cs;
}
@@ -800,10 +801,10 @@ public abstract class CardPanel extends VirtualMediaPanel
/**
* Clears an array of sprites from the specified list and from the panel.
*/
protected void clearSprites (ArrayList sprites)
protected void clearSprites (List<CardSprite> sprites)
{
for (Iterator it = sprites.iterator(); it.hasNext(); ) {
removeSprite((CardSprite)it.next());
for (Iterator<CardSprite> it = sprites.iterator(); it.hasNext(); ) {
removeSprite(it.next());
it.remove();
}
}
@@ -972,7 +973,7 @@ public abstract class CardPanel extends VirtualMediaPanel
/** Calls CardSpriteObserver.cardSpriteClicked. */
protected static class CardSpriteClickedOp implements
ObserverList.ObserverOp
ObserverList.ObserverOp<Object>
{
public CardSpriteClickedOp (CardSprite sprite, MouseEvent me)
{
@@ -995,7 +996,7 @@ public abstract class CardPanel extends VirtualMediaPanel
/** Calls CardSpriteObserver.cardSpriteEntered. */
protected static class CardSpriteEnteredOp implements
ObserverList.ObserverOp
ObserverList.ObserverOp<Object>
{
public CardSpriteEnteredOp (CardSprite sprite, MouseEvent me)
{
@@ -1006,8 +1007,7 @@ public abstract class CardPanel extends VirtualMediaPanel
public boolean apply (Object observer)
{
if (observer instanceof CardSpriteObserver) {
((CardSpriteObserver)observer).cardSpriteEntered(_sprite,
_me);
((CardSpriteObserver)observer).cardSpriteEntered(_sprite, _me);
}
return true;
}
@@ -1018,7 +1018,7 @@ public abstract class CardPanel extends VirtualMediaPanel
/** Calls CardSpriteObserver.cardSpriteExited. */
protected static class CardSpriteExitedOp implements
ObserverList.ObserverOp
ObserverList.ObserverOp<Object>
{
public CardSpriteExitedOp (CardSprite sprite, MouseEvent me)
{
@@ -1040,7 +1040,7 @@ public abstract class CardPanel extends VirtualMediaPanel
/** Calls CardSpriteObserver.cardSpriteDragged. */
protected static class CardSpriteDraggedOp implements
ObserverList.ObserverOp
ObserverList.ObserverOp<Object>
{
public CardSpriteDraggedOp (CardSprite sprite, MouseEvent me)
{
@@ -28,7 +28,7 @@ import com.threerings.presents.dobj.DSet;
/**
* Instances of this class represent individual playing cards.
*/
public class Card implements DSet.Entry, Comparable, CardCodes
public class Card implements DSet.Entry, Comparable<Card>, CardCodes
{
/**
* No-arg constructor for deserialization.
@@ -131,7 +131,7 @@ public class Card implements DSet.Entry, Comparable, CardCodes
}
// Documentation inherited.
public Comparable getKey ()
public Comparable<?> getKey ()
{
if (_key == null) {
_key = Byte.valueOf(_value);
@@ -167,9 +167,9 @@ public class Card implements DSet.Entry, Comparable, CardCodes
* @return -1, 0, or +1, depending on whether this card is less than,
* equal to, or greater than the other card
*/
public int compareTo (Object other)
public int compareTo (Card other)
{
int otherValue = ((Card)other)._value;
int otherValue = other._value;
if (_value > otherValue) {
return +1;
@@ -29,7 +29,7 @@ import com.threerings.util.StreamableArrayList;
/**
* Instances of this class represent decks of cards.
*/
public class Deck extends StreamableArrayList
public class Deck extends StreamableArrayList<Card>
implements CardCodes
{
/**
@@ -100,7 +100,7 @@ public class Deck extends StreamableArrayList
Hand hand = new Hand();
// use a sublist view to manipulate the top of the deck
List sublist = subList(dsize - size, dsize);
List<Card> sublist = subList(dsize - size, dsize);
hand.addAll(sublist);
sublist.clear();
@@ -53,9 +53,7 @@ public class TrickCardGameMarshaller extends InvocationMarshaller
// from interface TrickCardGameService
public void requestRematch (Client arg1)
{
sendRequest(arg1, REQUEST_REMATCH, new Object[] {
});
sendRequest(arg1, REQUEST_REMATCH, new Object[] {});
}
/** The method id used to dispatch {@link #sendCardsToPlayer} requests. */
@@ -23,6 +23,7 @@ package com.threerings.parlor.card.trick.server;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.Interval;
@@ -441,14 +442,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
*/
protected Card pickRandomPlayableCard (Hand hand)
{
ArrayList playableCards = new ArrayList();
List<Card> playableCards = new ArrayList<Card>();
for (int i = 0; i < hand.size(); i++) {
Card card = hand.get(i);
if (_trickCardGame.isCardPlayable(hand, card)) {
playableCards.add(card);
}
}
return (Card)RandomUtil.pickRandom(playableCards);
return RandomUtil.pickRandom(playableCards);
}
/**
@@ -21,7 +21,9 @@
package com.threerings.parlor.client;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
import com.samskivert.util.HashIntMap;
import com.threerings.util.Name;
@@ -138,7 +140,7 @@ public class ParlorDirector extends BasicDirector
// see what our observers have to say about it
boolean handled = false;
for (int i = 0; i < _grobs.size(); i++) {
GameReadyObserver grob = (GameReadyObserver)_grobs.get(i);
GameReadyObserver grob = _grobs.get(i);
handled = grob.receivedGameReady(gameOid) || handled;
}
@@ -172,7 +174,7 @@ public class ParlorDirector extends BasicDirector
public void receivedInviteResponse (int remoteId, int code, Object arg)
{
// look up the invitation record for this invitation
Invitation invite = (Invitation)_pendingInvites.get(remoteId);
Invitation invite = _pendingInvites.get(remoteId);
if (invite == null) {
log.warning("Have no record of invitation for which we received a response?! " +
"[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "].");
@@ -230,8 +232,8 @@ public class ParlorDirector extends BasicDirector
/** A table of acknowledged (but not yet accepted or refused) invitation requests, keyed on
* invitation id. */
protected HashIntMap _pendingInvites = new HashIntMap();
protected HashIntMap<Invitation> _pendingInvites = new HashIntMap<Invitation>();
/** We notify the entities on this list when we get a game ready notification. */
protected ArrayList _grobs = new ArrayList();
protected List<GameReadyObserver> _grobs = Lists.newArrayList();
}
@@ -58,7 +58,7 @@ import static com.threerings.parlor.Log.log;
* matchmaking takes place implements the {@link TableLobbyObject} interface.
*/
public class TableDirector extends BasicDirector
implements SetListener, TableService.ResultListener
implements SetListener<Table>, TableService.ResultListener
{
/**
* Creates a new table director to manage tables with the specified observer which will receive
@@ -227,10 +227,10 @@ public class TableDirector extends BasicDirector
}
// documentation inherited
public void entryAdded (EntryAddedEvent event)
public void entryAdded (EntryAddedEvent<Table> event)
{
if (event.getName().equals(_tableField)) {
Table table = (Table)event.getEntry();
Table table = event.getEntry();
// check to see if we just joined a table
checkSeatedness(table);
// now let the observer know what's up
@@ -239,10 +239,10 @@ public class TableDirector extends BasicDirector
}
// documentation inherited
public void entryUpdated (EntryUpdatedEvent event)
public void entryUpdated (EntryUpdatedEvent<Table> event)
{
if (event.getName().equals(_tableField)) {
Table table = (Table)event.getEntry();
Table table = event.getEntry();
// check to see if we just joined or left a table
checkSeatedness(table);
// now let the observer know what's up
@@ -251,7 +251,7 @@ public class TableDirector extends BasicDirector
}
// documentation inherited
public void entryRemoved (EntryRemovedEvent event)
public void entryRemoved (EntryRemovedEvent<Table> event)
{
if (event.getName().equals(_tableField)) {
int tableId = ((Integer) event.getKey()).intValue();
@@ -275,7 +275,7 @@ public class TableDirector extends BasicDirector
return;
}
Table table = (Table) _tlobj.getTables().get(tableId);
Table table = _tlobj.getTables().get(tableId);
if (table == null) {
log.warning("Table created, but where is it? [tableId=" + tableId + "]");
return;
@@ -40,7 +40,7 @@ public class ParlorMarshaller extends InvocationMarshaller
implements ParlorService
{
/**
* Marshalls results to implementations of {@link InviteListener}.
* Marshalls results to implementations of {@link ParlorService.InviteListener}.
*/
public static class InviteMarshaller extends ListenerMarshaller
implements InviteListener
@@ -380,7 +380,7 @@ public class Table
}
// documentation inherited
public Comparable getKey ()
public Comparable<?> getKey ()
{
return tableId;
}
@@ -45,7 +45,7 @@ public abstract class EntryFee extends SimpleStreamableObject
/**
* Attempts to reserve the entry fee.
*/
public abstract void reserveFee (BodyObject body, ResultListener listener);
public abstract void reserveFee (BodyObject body, ResultListener<Void> listener);
/**
* Returns the entry fee.
@@ -31,21 +31,20 @@ import com.threerings.presents.dobj.DSet;
* Contains information on a particular tourney participant.
*/
public class Participant extends SimpleStreamableObject
implements DSet.Entry, Comparable
implements DSet.Entry, Comparable<Participant>
{
/** The username of the participant. */
public Name username;
// documentation inherited from interface DSet.Entry
public Comparable getKey ()
public Comparable<?> getKey ()
{
return username;
}
// documentation inherited from interface Comparable
public int compareTo (Object o)
public int compareTo (Participant op)
{
Participant op = (Participant)o;
return username.compareTo(op.username);
}
@@ -50,7 +50,7 @@ public abstract class TourneyManager
*
* @return the oid of this manager's tourney object.
*/
public int init (TourneyConfig config, Comparable key)
public int init (TourneyConfig config, Comparable<?> key)
{
_config = config;
_key = key;
@@ -120,8 +120,8 @@ public abstract class TourneyManager
// make the assumption that they're going to get in
_trobj.addToParticipants(part);
ResultListener rl = new ResultListener() {
public void requestCompleted (Object result) {
ResultListener<Void> rl = new ResultListener<Void>() {
public void requestCompleted (Void result) {
listener.requestProcessed();
}
public void requestFailed (Exception cause) {
@@ -150,7 +150,7 @@ public abstract class TourneyManager
throw new InvocationException(TOO_LATE_LEAVE);
}
Comparable key = body.username;
Comparable<?> key = body.username;
if (!_trobj.participants.containsKey(key)) {
throw new InvocationException(NOT_IN_TOURNEY);
}
@@ -283,7 +283,7 @@ public abstract class TourneyManager
protected long _startTime;
/** The key this tourney is recorded under. */
protected Comparable _key;
protected Comparable<?> _key;
// services on which we depend
@Inject protected RootDObjectManager _omgr;
@@ -103,7 +103,7 @@ public abstract class TourniesManager
/**
* Called by the tourney manager to remove itself from the tournies.
*/
protected void releaseTourney (Comparable key)
protected void releaseTourney (Comparable<?> key)
{
_tourneys.remove(key);
}
@@ -148,7 +148,7 @@ public abstract class TourniesManager
protected int _tourneyCount;
/** Holds all the current tournies in the game. */
protected Map<Comparable, TourneyManager> _tourneys = Maps.newHashMap();
protected Map<Comparable<?>, TourneyManager> _tourneys = Maps.newHashMap();
// our dependencies
@Inject protected RootDObjectManager _omgr;
@@ -23,6 +23,7 @@ package com.threerings.parlor.util;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
import com.samskivert.swing.Controller;
import com.samskivert.util.CollectionUtil;
@@ -100,7 +101,7 @@ public class RobotPlayer extends Interval
{
// post a random key press command
int idx = RandomUtil.getInt(_press.size());
String command = (String)_press.get(idx);
String command = _press.get(idx);
// Log.info("Posting artificial command [cmd=" + command + "].");
Controller.postAction(_target, command);
}
@@ -115,10 +116,10 @@ public class RobotPlayer extends Interval
protected long _robotDelay = DEFAULT_ROBOT_DELAY;
/** The list of available key press action commands. */
protected ArrayList _press = new ArrayList();
protected List<String> _press = new ArrayList<String>();
/** The list of available key release action commands. */
protected ArrayList _release = new ArrayList();
protected List<String> _release = new ArrayList<String>();
/** The key translator that describes available keys and commands. */
protected KeyTranslator _xlate;