Fixed a bunch of type safety bits pointed out by the latest version of Eclipse.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5274 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-07-30 12:58:51 +00:00
parent ca4c5897fb
commit 725f656197
77 changed files with 248 additions and 250 deletions
@@ -27,7 +27,7 @@ import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Integer; import com.threerings.util.Integer;
/** /**
* Provides the implementation of the {@link BureauService} interface * Provides the implementation of the <code>BureauService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
@@ -36,7 +36,7 @@ import com.threerings.util.Integer;
public class BureauMarshaller extends InvocationMarshaller public class BureauMarshaller extends InvocationMarshaller
implements BureauService implements BureauService
{ {
/** The method id used to dispatch {@link #agentCreated} requests. */ /** The method id used to dispatch <code>agentCreated</code> requests. */
public static const AGENT_CREATED :int = 1; public static const AGENT_CREATED :int = 1;
// from interface BureauService // from interface BureauService
@@ -47,7 +47,7 @@ public class BureauMarshaller extends InvocationMarshaller
]); ]);
} }
/** The method id used to dispatch {@link #agentCreationFailed} requests. */ /** The method id used to dispatch <code>agentCreationFailed</code> requests. */
public static const AGENT_CREATION_FAILED :int = 2; public static const AGENT_CREATION_FAILED :int = 2;
// from interface BureauService // from interface BureauService
@@ -58,7 +58,7 @@ public class BureauMarshaller extends InvocationMarshaller
]); ]);
} }
/** The method id used to dispatch {@link #agentDestroyed} requests. */ /** The method id used to dispatch <code>agentDestroyed</code> requests. */
public static const AGENT_DESTROYED :int = 3; public static const AGENT_DESTROYED :int = 3;
// from interface BureauService // from interface BureauService
@@ -69,7 +69,7 @@ public class BureauMarshaller extends InvocationMarshaller
]); ]);
} }
/** The method id used to dispatch {@link #bureauInitialized} requests. */ /** The method id used to dispatch <code>bureauInitialized</code> requests. */
public static const BUREAU_INITIALIZED :int = 4; public static const BUREAU_INITIALIZED :int = 4;
// from interface BureauService // from interface BureauService
@@ -30,7 +30,7 @@ import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.util.Name; import com.threerings.util.Name;
/** /**
* Provides the implementation of the {@link ChatService} interface * Provides the implementation of the <code>ChatService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
@@ -39,7 +39,7 @@ import com.threerings.util.Name;
public class ChatMarshaller extends InvocationMarshaller public class ChatMarshaller extends InvocationMarshaller
implements ChatService implements ChatService
{ {
/** The method id used to dispatch {@link #away} requests. */ /** The method id used to dispatch <code>away</code> requests. */
public static const AWAY :int = 1; public static const AWAY :int = 1;
// from interface ChatService // from interface ChatService
@@ -50,7 +50,7 @@ public class ChatMarshaller extends InvocationMarshaller
]); ]);
} }
/** The method id used to dispatch {@link #broadcast} requests. */ /** The method id used to dispatch <code>broadcast</code> requests. */
public static const BROADCAST :int = 2; public static const BROADCAST :int = 2;
// from interface ChatService // from interface ChatService
@@ -63,7 +63,7 @@ public class ChatMarshaller extends InvocationMarshaller
]); ]);
} }
/** The method id used to dispatch {@link #tell} requests. */ /** The method id used to dispatch <code>tell</code> requests. */
public static const TELL :int = 3; public static const TELL :int = 3;
// from interface ChatService // from interface ChatService
@@ -31,7 +31,7 @@ import com.threerings.util.Long;
public class ChatMarshaller_TellMarshaller public class ChatMarshaller_TellMarshaller
extends InvocationMarshaller_ListenerMarshaller extends InvocationMarshaller_ListenerMarshaller
{ {
/** The method id used to dispatch {@link #tellSucceeded} responses. */ /** The method id used to dispatch <code>tellSucceeded</code> responses. */
public static const TELL_SUCCEEDED :int = 1; public static const TELL_SUCCEEDED :int = 1;
// from InvocationMarshaller_ListenerMarshaller // from InvocationMarshaller_ListenerMarshaller
@@ -27,7 +27,7 @@ import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Byte; import com.threerings.util.Byte;
/** /**
* Provides the implementation of the {@link SpeakService} interface * Provides the implementation of the <code>SpeakService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
@@ -36,7 +36,7 @@ import com.threerings.util.Byte;
public class SpeakMarshaller extends InvocationMarshaller public class SpeakMarshaller extends InvocationMarshaller
implements SpeakService implements SpeakService
{ {
/** The method id used to dispatch {@link #speak} requests. */ /** The method id used to dispatch <code>speak</code> requests. */
public static const SPEAK :int = 1; public static const SPEAK :int = 1;
// from interface SpeakService // from interface SpeakService
@@ -27,7 +27,7 @@ import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.langBoolean; import com.threerings.util.langBoolean;
/** /**
* Provides the implementation of the {@link BodyService} interface * Provides the implementation of the <code>BodyService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
@@ -36,7 +36,7 @@ import com.threerings.util.langBoolean;
public class BodyMarshaller extends InvocationMarshaller public class BodyMarshaller extends InvocationMarshaller
implements BodyService implements BodyService
{ {
/** The method id used to dispatch {@link #setIdle} requests. */ /** The method id used to dispatch <code>setIdle</code> requests. */
public static const SET_IDLE :int = 1; public static const SET_IDLE :int = 1;
// from interface BodyService // from interface BodyService
@@ -28,7 +28,7 @@ import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.util.Integer; import com.threerings.util.Integer;
/** /**
* Provides the implementation of the {@link LocationService} interface * Provides the implementation of the <code>LocationService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
@@ -37,7 +37,7 @@ import com.threerings.util.Integer;
public class LocationMarshaller extends InvocationMarshaller public class LocationMarshaller extends InvocationMarshaller
implements LocationService implements LocationService
{ {
/** The method id used to dispatch {@link #leavePlace} requests. */ /** The method id used to dispatch <code>leavePlace</code> requests. */
public static const LEAVE_PLACE :int = 1; public static const LEAVE_PLACE :int = 1;
// from interface LocationService // from interface LocationService
@@ -48,7 +48,7 @@ public class LocationMarshaller extends InvocationMarshaller
]); ]);
} }
/** The method id used to dispatch {@link #moveTo} requests. */ /** The method id used to dispatch <code>moveTo</code> requests. */
public static const MOVE_TO :int = 2; public static const MOVE_TO :int = 2;
// from interface LocationService // from interface LocationService
@@ -30,7 +30,7 @@ import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
public class LocationMarshaller_MoveMarshaller public class LocationMarshaller_MoveMarshaller
extends InvocationMarshaller_ListenerMarshaller extends InvocationMarshaller_ListenerMarshaller
{ {
/** The method id used to dispatch {@link #moveSucceeded} responses. */ /** The method id used to dispatch <code>moveSucceeded</code> responses. */
public static const MOVE_SUCCEEDED :int = 1; public static const MOVE_SUCCEEDED :int = 1;
// from InvocationMarshaller_ListenerMarshaller // from InvocationMarshaller_ListenerMarshaller
@@ -26,7 +26,7 @@ import com.threerings.presents.client.TimeBaseService;
import com.threerings.presents.client.TimeBaseService_GotTimeBaseListener; import com.threerings.presents.client.TimeBaseService_GotTimeBaseListener;
/** /**
* Provides the implementation of the {@link TimeBaseService} interface * Provides the implementation of the <code>TimeBaseService</code> interface
* that marshalls the arguments and delivers the request to the provider * that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
@@ -35,7 +35,7 @@ import com.threerings.presents.client.TimeBaseService_GotTimeBaseListener;
public class TimeBaseMarshaller extends InvocationMarshaller public class TimeBaseMarshaller extends InvocationMarshaller
implements TimeBaseService implements TimeBaseService
{ {
/** The method id used to dispatch {@link #getTimeOid} requests. */ /** The method id used to dispatch <code>getTimeOid</code> requests. */
public static const GET_TIME_OID :int = 1; public static const GET_TIME_OID :int = 1;
// from interface TimeBaseService // from interface TimeBaseService
@@ -29,7 +29,7 @@ import com.threerings.presents.client.TimeBaseService_GotTimeBaseListener;
public class TimeBaseMarshaller_GotTimeBaseMarshaller public class TimeBaseMarshaller_GotTimeBaseMarshaller
extends InvocationMarshaller_ListenerMarshaller extends InvocationMarshaller_ListenerMarshaller
{ {
/** The method id used to dispatch {@link #gotTimeOid} responses. */ /** The method id used to dispatch <code>gotTimeOid</code> responses. */
public static const GOT_TIME_OID :int = 1; public static const GOT_TIME_OID :int = 1;
// from InvocationMarshaller_ListenerMarshaller // from InvocationMarshaller_ListenerMarshaller
@@ -57,7 +57,7 @@ public class DSetEditor<E extends DSet.Entry> extends JPanel
* @param setName The name of the set in the object. * @param setName The name of the set in the object.
* @param entryClass the Class of the DSet.Entry elements contained in the set. * @param entryClass the Class of the DSet.Entry elements contained in the set.
*/ */
public DSetEditor (DObject setter, String setName, Class entryClass) public DSetEditor (DObject setter, String setName, Class<?> entryClass)
{ {
this(setter, setName, entryClass, null); this(setter, setName, entryClass, null);
} }
@@ -70,7 +70,7 @@ public class DSetEditor<E extends DSet.Entry> extends JPanel
* @param entryClass the Class of the DSet.Entry elements contained in the set. * @param entryClass the Class of the DSet.Entry elements contained in the set.
* @param editableFields the names of the fields in the entryClass that should be editable. * @param editableFields the names of the fields in the entryClass that should be editable.
*/ */
public DSetEditor (DObject setter, String setName, Class entryClass, public DSetEditor (DObject setter, String setName, Class<?> entryClass,
String[] editableFields) String[] editableFields)
{ {
this(setter, setName, entryClass, editableFields, null); this(setter, setName, entryClass, editableFields, null);
@@ -85,7 +85,7 @@ public class DSetEditor<E extends DSet.Entry> extends JPanel
* @param editableFields the names of the fields in the entryClass that should be editable. * @param editableFields the names of the fields in the entryClass that should be editable.
* @param interp The FieldInterpreter to use. * @param interp The FieldInterpreter to use.
*/ */
public DSetEditor (DObject setter, String setName, Class entryClass, public DSetEditor (DObject setter, String setName, Class<?> entryClass,
String[] editableFields, ObjectEditorTable.FieldInterpreter interp) String[] editableFields, ObjectEditorTable.FieldInterpreter interp)
{ {
super(new BorderLayout()); super(new BorderLayout());
@@ -147,8 +147,7 @@ public class DSetEditor<E extends DSet.Entry> extends JPanel
{ {
if (event.getName().equals(_setName)) { if (event.getName().equals(_setName)) {
E entry = event.getEntry(); E entry = event.getEntry();
@SuppressWarnings("unchecked") Comparable<Object> key = entry.getKey(); int index = _keys.insertSorted(getKey(entry));
int index = _keys.insertSorted(key);
_table.insertDatum(entry, index); _table.insertDatum(entry, index);
} }
} }
@@ -157,7 +156,7 @@ public class DSetEditor<E extends DSet.Entry> extends JPanel
public void entryRemoved (EntryRemovedEvent<E> event) public void entryRemoved (EntryRemovedEvent<E> event)
{ {
if (event.getName().equals(_setName)) { if (event.getName().equals(_setName)) {
Comparable key = event.getKey(); Comparable<?> key = event.getKey();
int index = _keys.indexOf(key); int index = _keys.indexOf(key);
_keys.remove(index); _keys.remove(index);
_table.removeDatum(index); _table.removeDatum(index);
@@ -197,12 +196,17 @@ public class DSetEditor<E extends DSet.Entry> extends JPanel
@SuppressWarnings("unchecked") E[] entries = (E[])new DSet.Entry[_set.size()]; @SuppressWarnings("unchecked") E[] entries = (E[])new DSet.Entry[_set.size()];
_set.toArray(entries); _set.toArray(entries);
for (int ii = 0; ii < entries.length; ii++) { for (int ii = 0; ii < entries.length; ii++) {
@SuppressWarnings("unchecked") Comparable<Object> key = entries[ii].getKey(); _keys.insertSorted(getKey(entries[ii]));
_keys.insertSorted(key);
} }
_table.setData(entries); // this works because DSet itself is sorted _table.setData(entries); // this works because DSet itself is sorted
} }
@SuppressWarnings("unchecked")
protected static Comparable<Object> getKey (DSet.Entry entry)
{
return (Comparable<Object>)entry.getKey();
}
/** The object that contains the set we're displaying. */ /** The object that contains the set we're displaying. */
protected DObject _setter; protected DObject _setter;
@@ -47,7 +47,6 @@ public class AdminDispatcher extends InvocationDispatcher<AdminMarshaller>
return new AdminMarshaller(); return new AdminMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -67,7 +67,6 @@ import static com.threerings.admin.Log.log;
*/ */
public abstract class ConfigRegistry public abstract class ConfigRegistry
{ {
/** /**
* Creates a ConfigRegistry that isn't transitioning. * Creates a ConfigRegistry that isn't transitioning.
*/ */
@@ -138,7 +137,7 @@ public abstract class ConfigRegistry
* Contains all necessary info for a configuration object registration. * Contains all necessary info for a configuration object registration.
*/ */
protected abstract class ObjectRecord protected abstract class ObjectRecord
implements AttributeChangeListener, SetListener, ElementUpdateListener implements AttributeChangeListener, SetListener<DSet.Entry>, ElementUpdateListener
{ {
public DObject object; public DObject object;
@@ -150,7 +149,7 @@ public abstract class ConfigRegistry
public void init () public void init ()
{ {
// read in the initial configuration settings from the persistent config repository // read in the initial configuration settings from the persistent config repository
Class cclass = object.getClass(); Class<?> cclass = object.getClass();
try { try {
Field[] fields = cclass.getFields(); Field[] fields = cclass.getFields();
for (int ii = 0; ii < fields.length; ii++) { for (int ii = 0; ii < fields.length; ii++) {
@@ -172,19 +171,19 @@ public abstract class ConfigRegistry
} }
// from SetListener // from SetListener
public void entryAdded (EntryAddedEvent event) public void entryAdded (EntryAddedEvent<DSet.Entry> event)
{ {
serializeAttribute(event.getName()); serializeAttribute(event.getName());
} }
// from SetListener // from SetListener
public void entryUpdated (EntryUpdatedEvent event) public void entryUpdated (EntryUpdatedEvent<DSet.Entry> event)
{ {
serializeAttribute(event.getName()); serializeAttribute(event.getName());
} }
// from SetListener // from SetListener
public void entryRemoved (EntryRemovedEvent event) public void entryRemoved (EntryRemovedEvent<DSet.Entry> event)
{ {
serializeAttribute(event.getName()); serializeAttribute(event.getName());
} }
@@ -252,7 +251,7 @@ public abstract class ConfigRegistry
protected void initField (Field field) protected void initField (Field field)
{ {
String key = nameToKey(field.getName()); String key = nameToKey(field.getName());
Class type = field.getType(); Class<?> type = field.getType();
try { try {
if (type.equals(Boolean.TYPE)) { if (type.equals(Boolean.TYPE)) {
@@ -46,7 +46,6 @@ public class BureauDispatcher extends InvocationDispatcher<BureauMarshaller>
return new BureauMarshaller(); return new BureauMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -80,7 +80,7 @@ public class ChatDirector extends BasicDirector
/** /**
* Called when the list of chatters has been changed. * Called when the list of chatters has been changed.
*/ */
void chattersUpdated (Iterator chatternames); void chattersUpdated (Iterator<Name> chatternames);
} }
/** /**
@@ -49,7 +49,6 @@ public class ChatDispatcher extends InvocationDispatcher<ChatMarshaller>
return new ChatMarshaller(); return new ChatMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -46,7 +46,6 @@ public class SpeakDispatcher extends InvocationDispatcher<SpeakMarshaller>
return new SpeakMarshaller(); return new SpeakMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -57,7 +57,7 @@ import com.threerings.crowd.util.CrowdContext;
* what's in the cache. * what's in the cache.
*/ */
public class OccupantDirector extends BasicDirector public class OccupantDirector extends BasicDirector
implements LocationObserver, SetListener implements LocationObserver, SetListener<OccupantInfo>
{ {
/** /**
* Constructs a new occupant director with the supplied context. * Constructs a new occupant director with the supplied context.
@@ -148,7 +148,7 @@ public class OccupantDirector extends BasicDirector
/** /**
* Deals with all of the processing when an occupant shows up. * Deals with all of the processing when an occupant shows up.
*/ */
public void entryAdded (EntryAddedEvent event) public void entryAdded (EntryAddedEvent<OccupantInfo> event)
{ {
// bail if this isn't for the OCCUPANT_INFO field // bail if this isn't for the OCCUPANT_INFO field
if (!event.getName().equals(PlaceObject.OCCUPANT_INFO)) { if (!event.getName().equals(PlaceObject.OCCUPANT_INFO)) {
@@ -156,7 +156,7 @@ public class OccupantDirector extends BasicDirector
} }
// now let the occupant observers know what's up // now let the occupant observers know what's up
final OccupantInfo info = (OccupantInfo)event.getEntry(); final OccupantInfo info = event.getEntry();
_observers.apply(new ObserverList.ObserverOp<OccupantObserver>() { _observers.apply(new ObserverList.ObserverOp<OccupantObserver>() {
public boolean apply (OccupantObserver observer) { public boolean apply (OccupantObserver observer) {
observer.occupantEntered(info); observer.occupantEntered(info);
@@ -168,7 +168,7 @@ public class OccupantDirector extends BasicDirector
/** /**
* Deals with all of the processing when an occupant is updated. * Deals with all of the processing when an occupant is updated.
*/ */
public void entryUpdated (EntryUpdatedEvent event) public void entryUpdated (EntryUpdatedEvent<OccupantInfo> event)
{ {
// bail if this isn't for the OCCUPANT_INFO field // bail if this isn't for the OCCUPANT_INFO field
if (!event.getName().equals(PlaceObject.OCCUPANT_INFO)) { if (!event.getName().equals(PlaceObject.OCCUPANT_INFO)) {
@@ -176,8 +176,8 @@ public class OccupantDirector extends BasicDirector
} }
// now let the occupant observers know what's up // now let the occupant observers know what's up
final OccupantInfo info = (OccupantInfo)event.getEntry(); final OccupantInfo info = event.getEntry();
final OccupantInfo oinfo = (OccupantInfo)event.getOldEntry(); final OccupantInfo oinfo = event.getOldEntry();
_observers.apply(new ObserverList.ObserverOp<OccupantObserver>() { _observers.apply(new ObserverList.ObserverOp<OccupantObserver>() {
public boolean apply (OccupantObserver observer) { public boolean apply (OccupantObserver observer) {
observer.occupantUpdated(oinfo, info); observer.occupantUpdated(oinfo, info);
@@ -189,7 +189,7 @@ public class OccupantDirector extends BasicDirector
/** /**
* Deals with all of the processing when an occupant leaves. * Deals with all of the processing when an occupant leaves.
*/ */
public void entryRemoved (EntryRemovedEvent event) public void entryRemoved (EntryRemovedEvent<OccupantInfo> event)
{ {
// bail if this isn't for the OCCUPANT_INFO field // bail if this isn't for the OCCUPANT_INFO field
if (!event.getName().equals(PlaceObject.OCCUPANT_INFO)) { if (!event.getName().equals(PlaceObject.OCCUPANT_INFO)) {
@@ -197,7 +197,7 @@ public class OccupantDirector extends BasicDirector
} }
// let the occupant observers know what's up // let the occupant observers know what's up
final OccupantInfo oinfo = (OccupantInfo)event.getOldEntry(); final OccupantInfo oinfo = event.getOldEntry();
_observers.apply(new ObserverList.ObserverOp<OccupantObserver>() { _observers.apply(new ObserverList.ObserverOp<OccupantObserver>() {
public boolean apply (OccupantObserver observer) { public boolean apply (OccupantObserver observer) {
observer.occupantLeft(oinfo); observer.occupantLeft(oinfo);
@@ -207,8 +207,7 @@ public class OccupantDirector extends BasicDirector
} }
/** The occupant observers to keep abreast of occupant antics. */ /** The occupant observers to keep abreast of occupant antics. */
protected ObserverList<OccupantObserver> _observers = protected ObserverList<OccupantObserver> _observers = ObserverList.newSafeInOrder();
new ObserverList<OccupantObserver>(ObserverList.SAFE_IN_ORDER_NOTIFY);
/** The user's current location. */ /** The user's current location. */
protected PlaceObject _place; protected PlaceObject _place;
@@ -85,7 +85,7 @@ public class OccupantInfo extends SimpleStreamableObject
} }
// documentation inherited // documentation inherited
public Comparable getKey () public Comparable<?> getKey ()
{ {
return bodyOid; return bodyOid;
} }
@@ -52,7 +52,7 @@ public abstract class PlaceConfig extends SimpleStreamableObject
* @deprecated Override {@link #createController} directly. * @deprecated Override {@link #createController} directly.
*/ */
@Deprecated @Deprecated
public Class getControllerClass () public Class<?> getControllerClass ()
{ {
return null; return null;
} }
@@ -62,7 +62,7 @@ public abstract class PlaceConfig extends SimpleStreamableObject
*/ */
public PlaceController createController () public PlaceController createController ()
{ {
Class cclass = getControllerClass(); Class<?> cclass = getControllerClass();
if (cclass == null) { if (cclass == null) {
throw new RuntimeException( throw new RuntimeException(
"PlaceConfig.createController() must be overridden."); "PlaceConfig.createController() must be overridden.");
@@ -21,8 +21,6 @@
package com.threerings.crowd.data; package com.threerings.crowd.data;
import java.util.Iterator;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
@@ -124,9 +122,7 @@ public class PlaceObject extends DObject
public OccupantInfo getOccupantInfo (Name username) public OccupantInfo getOccupantInfo (Name username)
{ {
try { try {
Iterator iter = occupantInfo.iterator(); for (OccupantInfo info : occupantInfo) {
while (iter.hasNext()) {
OccupantInfo info = (OccupantInfo)iter.next();
if (info.username.equals(username)) { if (info.username.equals(username)) {
return info; return info;
} }
@@ -181,7 +177,7 @@ public class PlaceObject extends DObject
* the <code>occupantInfo</code> set. The set will not change until the * the <code>occupantInfo</code> set. The set will not change until the
* event is actually propagated through the system. * event is actually propagated through the system.
*/ */
public void removeFromOccupantInfo (Comparable key) public void removeFromOccupantInfo (Comparable<?> key)
{ {
requestEntryRemove(OCCUPANT_INFO, occupantInfo, key); requestEntryRemove(OCCUPANT_INFO, occupantInfo, key);
} }
@@ -209,8 +205,7 @@ public class PlaceObject extends DObject
public void setOccupantInfo (DSet<OccupantInfo> value) public void setOccupantInfo (DSet<OccupantInfo> value)
{ {
requestAttributeChange(OCCUPANT_INFO, value, this.occupantInfo); requestAttributeChange(OCCUPANT_INFO, value, this.occupantInfo);
@SuppressWarnings("unchecked") DSet<OccupantInfo> clone = DSet<OccupantInfo> clone = (value == null) ? null : value.typedClone();
(value == null) ? null : value.typedClone();
this.occupantInfo = clone; this.occupantInfo = clone;
} }
@@ -34,7 +34,7 @@ public class CrowdClientInfo extends ClientInfo
public Name visibleName; public Name visibleName;
@Override // documentation inherited @Override // documentation inherited
public Comparable getKey () public Comparable<?> getKey ()
{ {
// the PeerManager works in such a way that we can override our client // the PeerManager works in such a way that we can override our client
// info key and things still work properly; all inter-server // info key and things still work properly; all inter-server
@@ -49,7 +49,6 @@ public class CrowdPeerDispatcher extends InvocationDispatcher<CrowdPeerMarshalle
return new CrowdPeerMarshaller(); return new CrowdPeerMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -46,7 +46,6 @@ public class BodyDispatcher extends InvocationDispatcher<BodyMarshaller>
return new BodyMarshaller(); return new BodyMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -43,10 +43,11 @@ public class CrowdObjectAccess
public static AccessController PLACE = new AccessController() public static AccessController PLACE = new AccessController()
{ {
// documentation inherited from interface // documentation inherited from interface
public boolean allowSubscribe (DObject object, Subscriber sub) public boolean allowSubscribe (DObject object, Subscriber<?> sub)
{ {
if (sub instanceof CrowdClient) { if (CrowdClient.class.isInstance(sub)) {
ClientObject co = ((CrowdClient)sub).getClientObject(); @SuppressWarnings("unchecked") ClientObject co =
((CrowdClient)sub).getClientObject();
return ((PlaceObject)object).occupants.contains(co.getOid()); return ((PlaceObject)object).occupants.contains(co.getOid());
} }
return true; return true;
@@ -47,7 +47,6 @@ public class LocationDispatcher extends InvocationDispatcher<LocationMarshaller>
return new LocationMarshaller(); return new LocationMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -35,6 +35,7 @@ import com.samskivert.util.StringUtil;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.AccessController; import com.threerings.presents.dobj.AccessController;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.DynamicListener; import com.threerings.presents.dobj.DynamicListener;
import com.threerings.presents.dobj.EntryUpdatedEvent; import com.threerings.presents.dobj.EntryUpdatedEvent;
import com.threerings.presents.dobj.MessageEvent; import com.threerings.presents.dobj.MessageEvent;
@@ -381,13 +382,13 @@ public class PlaceManager
// Lazily create our dispatcher now that it's actually getting a message // Lazily create our dispatcher now that it's actually getting a message
if (_dispatcher == null) { if (_dispatcher == null) {
Class clazz = getClass(); Class<?> clazz = getClass();
MethodFinder finder = _dispatcherFinders.get(clazz); MethodFinder finder = _dispatcherFinders.get(clazz);
if (finder == null) { if (finder == null) {
finder = new MethodFinder(clazz); finder = new MethodFinder(clazz);
_dispatcherFinders.put(clazz, finder); _dispatcherFinders.put(clazz, finder);
} }
_dispatcher = new DynamicListener(this, finder); _dispatcher = new DynamicListener<DSet.Entry>(this, finder);
} }
_dispatcher.dispatchMethod(event.getName(), nargs); _dispatcher.dispatchMethod(event.getName(), nargs);
} }
@@ -707,11 +708,11 @@ public class PlaceManager
} }
/** Listens for occupant updates. */ /** Listens for occupant updates. */
protected SetAdapter _bodyUpdater = new SetAdapter() { protected SetAdapter<OccupantInfo> _bodyUpdater = new SetAdapter<OccupantInfo>() {
@Override @Override
public void entryUpdated (EntryUpdatedEvent event) { public void entryUpdated (EntryUpdatedEvent<OccupantInfo> event) {
if (event.getName().equals(PlaceObject.OCCUPANT_INFO)) { if (event.getName().equals(PlaceObject.OCCUPANT_INFO)) {
bodyUpdated((OccupantInfo)event.getEntry()); bodyUpdated(event.getEntry());
} }
} }
}; };
@@ -748,7 +749,7 @@ public class PlaceManager
protected Interval _shutdownInterval; protected Interval _shutdownInterval;
/** Used to do method lookup magic when we receive message events. */ /** Used to do method lookup magic when we receive message events. */
protected DynamicListener _dispatcher; protected DynamicListener<?> _dispatcher;
/** Maps from a PlaceManager subclass to a MethodFinder for it. When there are many many /** Maps from a PlaceManager subclass to a MethodFinder for it. When there are many many
* instances of a PlaceManager in existence, having a MethodFinder instance for each gets quite * instances of a PlaceManager in existence, having a MethodFinder instance for each gets quite
@@ -35,7 +35,7 @@ import java.util.RandomAccess;
public class BasicStreamers public class BasicStreamers
{ {
/** An array of types for all of the basic streamers. */ /** An array of types for all of the basic streamers. */
public static Class[] BSTREAMER_TYPES = { public static Class<?>[] BSTREAMER_TYPES = {
Boolean.class, Boolean.class,
Byte.class, Byte.class,
Short.class, Short.class,
@@ -419,7 +419,7 @@ public class BasicStreamers
public void writeObject (Object object, ObjectOutputStream out, boolean useWriter) public void writeObject (Object object, ObjectOutputStream out, boolean useWriter)
throws IOException throws IOException
{ {
writeList(out, (List)object); writeList(out, (List<?>)object);
} }
} }
@@ -538,7 +538,7 @@ public class BasicStreamers
return value; return value;
} }
public static ArrayList readList (ObjectInputStream ins) public static ArrayList<?> readList (ObjectInputStream ins)
throws IOException, ClassNotFoundException throws IOException, ClassNotFoundException
{ {
int ecount = ins.readInt(); int ecount = ins.readInt();
@@ -637,7 +637,7 @@ public class BasicStreamers
} }
} }
public static void writeList (ObjectOutputStream out, List value) public static void writeList (ObjectOutputStream out, List<?> value)
throws IOException throws IOException
{ {
int ecount = value.size(); int ecount = value.size();
+2 -2
View File
@@ -28,10 +28,10 @@ package com.threerings.io;
class ClassMapping class ClassMapping
{ {
public short code; public short code;
public Class sclass; public Class<?> sclass;
public Streamer streamer; public Streamer streamer;
public ClassMapping (short code, Class sclass, Streamer streamer) public ClassMapping (short code, Class<?> sclass, Streamer streamer)
{ {
this.code = code; this.code = code;
this.sclass = sclass; this.sclass = sclass;
@@ -79,7 +79,7 @@ public abstract class FieldMarshaller
} }
} }
Class ftype = field.getType(); Class<?> ftype = field.getType();
if (ftype.isInterface()) { if (ftype.isInterface()) {
// if the class is a pure interface, use Object. // if the class is a pure interface, use Object.
ftype = Object.class; ftype = Object.class;
@@ -212,7 +212,7 @@ public abstract class FieldMarshaller
protected static void createMarshallers () protected static void createMarshallers ()
{ {
// create our table // create our table
_marshallers = new HashMap<Class, FieldMarshaller>(); _marshallers = new HashMap<Class<?>, FieldMarshaller>();
// create a generic marshaller for streamable instances // create a generic marshaller for streamable instances
FieldMarshaller gmarsh = new FieldMarshaller() { FieldMarshaller gmarsh = new FieldMarshaller() {
@@ -354,11 +354,11 @@ public abstract class FieldMarshaller
} }
/** Contains a mapping from field type to field marshaller instance for that type. */ /** Contains a mapping from field type to field marshaller instance for that type. */
protected static HashMap<Class, FieldMarshaller> _marshallers; protected static HashMap<Class<?>, FieldMarshaller> _marshallers;
/** Defines the signature to a custom field reader method. */ /** Defines the signature to a custom field reader method. */
protected static final Class[] READER_ARGS = { ObjectInputStream.class }; protected static final Class<?>[] READER_ARGS = { ObjectInputStream.class };
/** Defines the signature to a custom field writer method. */ /** Defines the signature to a custom field writer method. */
protected static final Class[] WRITER_ARGS = { ObjectOutputStream.class }; protected static final Class<?>[] WRITER_ARGS = { ObjectOutputStream.class };
} }
@@ -166,7 +166,7 @@ public class ObjectInputStream extends DataInputStream
throws IOException, ClassNotFoundException throws IOException, ClassNotFoundException
{ {
// resolve the class and streamer // resolve the class and streamer
Class sclass = Class.forName(cname, true, _loader); Class<?> sclass = Class.forName(cname, true, _loader);
Streamer streamer = Streamer.getStreamer(sclass); Streamer streamer = Streamer.getStreamer(sclass);
if (STREAM_DEBUG) { if (STREAM_DEBUG) {
log.info(hashCode() + ": New class '" + cname + "' [code=" + code + "]."); log.info(hashCode() + ": New class '" + cname + "' [code=" + code + "].");
@@ -25,6 +25,7 @@ import java.io.OutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import static com.threerings.NaryaLog.log; import static com.threerings.NaryaLog.log;
@@ -71,11 +72,11 @@ public class ObjectOutputStream extends DataOutputStream
// create our classmap if necessary // create our classmap if necessary
if (_classmap == null) { if (_classmap == null) {
_classmap = new HashMap<Class, ClassMapping>(); _classmap = new HashMap<Class<?>, ClassMapping>();
} }
// otherwise, look up the class mapping record // otherwise, look up the class mapping record
Class sclass = Streamer.getStreamerClass(object); Class<?> sclass = Streamer.getStreamerClass(object);
ClassMapping cmap = _classmap.get(sclass); ClassMapping cmap = _classmap.get(sclass);
// create a class mapping for this class if we've not got one // create a class mapping for this class if we've not got one
@@ -108,7 +109,7 @@ public class ObjectOutputStream extends DataOutputStream
/** /**
* Creates and returns a new class mapping. * Creates and returns a new class mapping.
*/ */
protected ClassMapping createClassMapping (short code, Class sclass, Streamer streamer) protected ClassMapping createClassMapping (short code, Class<?> sclass, Streamer streamer)
{ {
return new ClassMapping(code, sclass, streamer); return new ClassMapping(code, sclass, streamer);
} }
@@ -135,7 +136,7 @@ public class ObjectOutputStream extends DataOutputStream
/** /**
* Writes out the mapping for a class. * Writes out the mapping for a class.
*/ */
protected void writeClassMapping (int code, Class sclass) protected void writeClassMapping (int code, Class<?> sclass)
throws IOException throws IOException
{ {
writeShort(code); writeShort(code);
@@ -200,7 +201,7 @@ public class ObjectOutputStream extends DataOutputStream
/** Used to map classes to numeric codes and the {@link Streamer} instance used to write /** Used to map classes to numeric codes and the {@link Streamer} instance used to write
* them. */ * them. */
protected HashMap<Class, ClassMapping> _classmap; protected Map<Class<?>, ClassMapping> _classmap;
/** A counter used to assign codes to streamed classes. */ /** A counter used to assign codes to streamed classes. */
protected short _nextCode = 1; protected short _nextCode = 1;
@@ -212,5 +213,5 @@ public class ObjectOutputStream extends DataOutputStream
protected Streamer _streamer; protected Streamer _streamer;
/** An optional set of class name translations to use when serializing objects. */ /** An optional set of class name translations to use when serializing objects. */
protected HashMap<String, String> _translations; protected Map<String, String> _translations;
} }
+17 -12
View File
@@ -34,6 +34,7 @@ import java.security.PrivilegedActionException;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -54,7 +55,7 @@ public class Streamer
/** /**
* Returns true if the supplied target class can be streamed using a streamer. * Returns true if the supplied target class can be streamed using a streamer.
*/ */
public synchronized static boolean isStreamable (Class target) public synchronized static boolean isStreamable (Class<?> target)
{ {
while (true) { while (true) {
// if we've got a streamer for it, it's good // if we've got a streamer for it, it's good
@@ -82,10 +83,10 @@ public class Streamer
* object's natural class, but for enum values, that might be its declaring class as enums use * object's natural class, but for enum values, that might be its declaring class as enums use
* classes in a way that would otherwise pollute our id to class mapping space. * classes in a way that would otherwise pollute our id to class mapping space.
*/ */
public static Class getStreamerClass (Object object) public static Class<?> getStreamerClass (Object object)
{ {
return (object instanceof Enum) ? return (object instanceof Enum) ?
((Enum)object).getDeclaringClass() : object.getClass(); ((Enum<?>)object).getDeclaringClass() : object.getClass();
} }
/** /**
@@ -100,7 +101,7 @@ public class Streamer
* {@link Streamable} and is not one of the basic object types (@see {@link * {@link Streamable} and is not one of the basic object types (@see {@link
* ObjectOutputStream}). * ObjectOutputStream}).
*/ */
public synchronized static Streamer getStreamer (final Class target) public synchronized static Streamer getStreamer (final Class<?> target)
throws IOException throws IOException
{ {
// if we have not yet initialized ourselves, do so now // if we have not yet initialized ourselves, do so now
@@ -211,7 +212,7 @@ public class Streamer
// if someone serializes an enum to a file and then adds a value to the enum, changing the // if someone serializes an enum to a file and then adds a value to the enum, changing the
// ordinal assignments) // ordinal assignments)
if (_target.isEnum()) { if (_target.isEnum()) {
out.writeUTF(((Enum)object).name()); out.writeUTF(((Enum<?>)object).name());
return; return;
} }
@@ -262,8 +263,9 @@ public class Streamer
if (ObjectInputStream.STREAM_DEBUG) { if (ObjectInputStream.STREAM_DEBUG) {
log.info(in.hashCode() + ": Creating enum '" + _target.getName() + "'."); log.info(in.hashCode() + ": Creating enum '" + _target.getName() + "'.");
} }
@SuppressWarnings("unchecked") Object value = Enum.valueOf(_target, in.readUTF()); @SuppressWarnings("unchecked") Class<EnumReader> eclass =
return value; (Class<EnumReader>)_target;
return Enum.valueOf(eclass, in.readUTF());
} else { } else {
if (ObjectInputStream.STREAM_DEBUG) { if (ObjectInputStream.STREAM_DEBUG) {
@@ -482,7 +484,7 @@ public class Streamer
*/ */
protected static void createStreamers () protected static void createStreamers ()
{ {
_streamers = new HashMap<Class, Streamer>(); _streamers = new HashMap<Class<?>, Streamer>();
// register all of the basic streamers // register all of the basic streamers
int bscount = BasicStreamers.BSTREAMER_TYPES.length; int bscount = BasicStreamers.BSTREAMER_TYPES.length;
@@ -492,8 +494,11 @@ public class Streamer
} }
} }
/** Used to coerce the type system into quietude when reading enums from the wire. */
protected static enum EnumReader { NOT_USED };
/** The class for which this streamer instance is configured. */ /** The class for which this streamer instance is configured. */
protected Class _target; protected Class<?> _target;
/** If our target class is an array, this is a reference to a streamer that can stream our /** If our target class is an array, this is a reference to a streamer that can stream our
* array elements, otherwise it is null. */ * array elements, otherwise it is null. */
@@ -513,7 +518,7 @@ public class Streamer
protected Method _writer; protected Method _writer;
/** Contains the mapping from class names to configured streamer instances. */ /** Contains the mapping from class names to configured streamer instances. */
protected static HashMap<Class, Streamer> _streamers; protected static Map<Class<?>, Streamer> _streamers;
/** A simple predicate to filter "NotStreamable" members from a Streamable object's fields. */ /** A simple predicate to filter "NotStreamable" members from a Streamable object's fields. */
protected static final Predicate<Field> _isStreamableFieldPred = new Predicate<Field>() { protected static final Predicate<Field> _isStreamableFieldPred = new Predicate<Field>() {
@@ -526,11 +531,11 @@ public class Streamer
protected static final String READER_METHOD_NAME = "readObject"; protected static final String READER_METHOD_NAME = "readObject";
/** The argument list for the custom reader method. */ /** The argument list for the custom reader method. */
protected static final Class[] READER_ARGS = { ObjectInputStream.class }; protected static final Class<?>[] READER_ARGS = { ObjectInputStream.class };
/** The name of the custom writer method. */ /** The name of the custom writer method. */
protected static final String WRITER_METHOD_NAME = "writeObject"; protected static final String WRITER_METHOD_NAME = "writeObject";
/** The argument list for the custom writer method. */ /** The argument list for the custom writer method. */
protected static final Class[] WRITER_ARGS = { ObjectOutputStream.class }; protected static final Class<?>[] WRITER_ARGS = { ObjectOutputStream.class };
} }
@@ -29,7 +29,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
* Sets the reference to the set that will hold the classes for which mappings have been * Sets the reference to the set that will hold the classes for which mappings have been
* written. * written.
*/ */
public void setMappedClasses (Set<Class> mappedClasses) public void setMappedClasses (Set<Class<?>> mappedClasses)
{ {
_mappedClasses = mappedClasses; _mappedClasses = mappedClasses;
} }
@@ -37,7 +37,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
/** /**
* Returns a reference to the set of classes for which mappings have been written. * Returns a reference to the set of classes for which mappings have been written.
*/ */
public Set<Class> getMappedClasses () public Set<Class<?>> getMappedClasses ()
{ {
return _mappedClasses; return _mappedClasses;
} }
@@ -46,7 +46,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
* Notes that the receiver has received the mappings for a group of classes, and thus that from * Notes that the receiver has received the mappings for a group of classes, and thus that from
* now on, only the class codes need be sent. * now on, only the class codes need be sent.
*/ */
public void noteMappingsReceived (Collection<Class> sclasses) public void noteMappingsReceived (Collection<Class<?>> sclasses)
{ {
// sanity check // sanity check
if (_classmap == null) { if (_classmap == null) {
@@ -54,7 +54,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
} }
// make each class's code positive to signify that we no longer need to send metadata // make each class's code positive to signify that we no longer need to send metadata
for (Class sclass : sclasses) { for (Class<?> sclass : sclasses) {
ClassMapping cmap = _classmap.get(sclass); ClassMapping cmap = _classmap.get(sclass);
if (cmap == null) { if (cmap == null) {
throw new RuntimeException("No class mapping for " + sclass.getName()); throw new RuntimeException("No class mapping for " + sclass.getName());
@@ -64,7 +64,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
} }
@Override // documentation inherited @Override // documentation inherited
protected ClassMapping createClassMapping (short code, Class sclass, Streamer streamer) protected ClassMapping createClassMapping (short code, Class<?> sclass, Streamer streamer)
{ {
// the negative class code indicates that we must rewrite the metadata for the first // the negative class code indicates that we must rewrite the metadata for the first
// instance in each go-round; when we are notified that the other side has cached the // instance in each go-round; when we are notified that the other side has cached the
@@ -98,7 +98,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
} }
@Override // documentation inherited @Override // documentation inherited
protected void writeClassMapping (int code, Class sclass) protected void writeClassMapping (int code, Class<?> sclass)
throws IOException throws IOException
{ {
super.writeClassMapping(code, sclass); super.writeClassMapping(code, sclass);
@@ -108,5 +108,5 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
} }
/** The set of classes for which we have written mappings. */ /** The set of classes for which we have written mappings. */
protected Set<Class> _mappedClasses = new HashSet<Class>(); protected Set<Class<?>> _mappedClasses = new HashSet<Class<?>>();
} }
@@ -252,7 +252,7 @@ public class Client
* matches. <em>Note also:</em> this method cannot be called until after the client has * matches. <em>Note also:</em> this method cannot be called until after the client has
* established a connection with the server and the distributed object manager is available. * established a connection with the server and the distributed object manager is available.
*/ */
public void registerFlushDelay (Class objclass, long delay) public void registerFlushDelay (Class<?> objclass, long delay)
{ {
ClientDObjectMgr omgr = (ClientDObjectMgr)getDObjectManager(); ClientDObjectMgr omgr = (ClientDObjectMgr)getDObjectManager();
omgr.registerFlushDelay(objclass, delay); omgr.registerFlushDelay(objclass, delay);
@@ -401,7 +401,7 @@ public class ClientDObjectMgr
* This is guaranteed to be invoked via the invoker and can safely do main thread type things * This is guaranteed to be invoked via the invoker and can safely do main thread type things
* like call back to the subscriber. * like call back to the subscriber.
*/ */
protected void doUnsubscribe (int oid, Subscriber target) protected void doUnsubscribe (int oid, Subscriber<?> target)
{ {
DObject dobj = _ocache.get(oid); DObject dobj = _ocache.get(oid);
if (dobj != null) { if (dobj != null) {
@@ -74,7 +74,7 @@ public interface InvocationReceiver
} }
// documentation inherited from interface // documentation inherited from interface
public Comparable getKey () public Comparable<?> getKey ()
{ {
return receiverCode; return receiverCode;
} }
@@ -139,7 +139,7 @@ public class ClientObject extends DObject
* the <code>receivers</code> set. The set will not change until the * the <code>receivers</code> set. The set will not change until the
* event is actually propagated through the system. * event is actually propagated through the system.
*/ */
public void removeFromReceivers (Comparable key) public void removeFromReceivers (Comparable<?> key)
{ {
requestEntryRemove(RECEIVERS, receivers, key); requestEntryRemove(RECEIVERS, receivers, key);
} }
@@ -167,8 +167,7 @@ public class ClientObject extends DObject
public void setReceivers (DSet<InvocationReceiver.Registration> value) public void setReceivers (DSet<InvocationReceiver.Registration> value)
{ {
requestAttributeChange(RECEIVERS, value, this.receivers); requestAttributeChange(RECEIVERS, value, this.receivers);
@SuppressWarnings("unchecked") DSet<InvocationReceiver.Registration> clone = DSet<InvocationReceiver.Registration> clone = (value == null) ? null : value.typedClone();
(value == null) ? null : value.typedClone();
this.receivers = clone; this.receivers = clone;
} }
// AUTO-GENERATED: METHODS END // AUTO-GENERATED: METHODS END
@@ -33,7 +33,7 @@ public interface AccessController
* Should return true if the supplied subscriber is allowed to * Should return true if the supplied subscriber is allowed to
* subscribe to the specified object. * subscribe to the specified object.
*/ */
boolean allowSubscribe (DObject object, Subscriber subscriber); boolean allowSubscribe (DObject object, Subscriber<?> subscriber);
/** /**
* Should return true if the supplied event is legal for dispatch on * Should return true if the supplied event is legal for dispatch on
@@ -131,7 +131,7 @@ public class AttributeChangedEvent extends NamedEvent
_oldValue = target.getAttribute(_name); _oldValue = target.getAttribute(_name);
Object value = _value; Object value = _value;
if (value != null) { if (value != null) {
Class vclass = value.getClass(); Class<?> vclass = value.getClass();
if (vclass.isPrimitive()) { if (vclass.isPrimitive()) {
// do nothing; we check this to avoid the more expensive isAssignableFrom check // do nothing; we check this to avoid the more expensive isAssignableFrom check
// on primitives which are far and away the most common case // on primitives which are far and away the most common case
@@ -141,7 +141,7 @@ public class AttributeChangedEvent extends NamedEvent
System.arraycopy(value, 0, clone, 0, length); System.arraycopy(value, 0, clone, 0, length);
value = clone; value = clone;
} else if (DSet.class.isAssignableFrom(vclass)) { } else if (DSet.class.isAssignableFrom(vclass)) {
value = ((DSet)value).clone(); value = ((DSet<?>)value).clone();
} }
} }
// pass the new value on to the object // pass the new value on to the object
@@ -202,7 +202,7 @@ public abstract class DEvent implements Streamable
/** Used to differentiate between null meaning we haven't initialized our old entry and null /** Used to differentiate between null meaning we haven't initialized our old entry and null
* being the actual old entry. */ * being the actual old entry. */
protected static final DSet.Entry UNSET_OLD_ENTRY = new DSet.Entry() { protected static final DSet.Entry UNSET_OLD_ENTRY = new DSet.Entry() {
public Comparable getKey () { public Comparable<?> getKey () {
return null; return null;
} }
}; };
@@ -25,7 +25,9 @@ import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.Map;
import com.google.common.collect.Maps;
import com.samskivert.util.ListUtil; import com.samskivert.util.ListUtil;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
@@ -151,7 +153,7 @@ public class DObject
* *
* @see DObjectManager#subscribeToObject * @see DObjectManager#subscribeToObject
*/ */
public void addSubscriber (Subscriber sub) public void addSubscriber (Subscriber<?> sub)
{ {
// only add the subscriber if they're not already there // only add the subscriber if they're not already there
Object[] subs = ListUtil.testAndAddRef(_subs, sub); Object[] subs = ListUtil.testAndAddRef(_subs, sub);
@@ -175,7 +177,7 @@ public class DObject
* *
* @see DObjectManager#unsubscribeFromObject * @see DObjectManager#unsubscribeFromObject
*/ */
public void removeSubscriber (Subscriber sub) public void removeSubscriber (Subscriber<?> sub)
{ {
if (ListUtil.clearRef(_subs, sub) != null) { if (ListUtil.clearRef(_subs, sub) != null) {
// if we removed something, check to see if we just removed the last subscriber from // if we removed something, check to see if we just removed the last subscriber from
@@ -291,7 +293,7 @@ public class DObject
/** /**
* Request to have the specified key removed from the specified DSet. * Request to have the specified key removed from the specified DSet.
*/ */
public void removeFromSet (String setName, Comparable key) public void removeFromSet (String setName, Comparable<?> key)
{ {
requestEntryRemove(setName, getSet(setName), key); requestEntryRemove(setName, getSet(setName), key);
} }
@@ -377,7 +379,7 @@ public class DObject
* *
* @return true if the subscriber has access to the object, false if they do not. * @return true if the subscriber has access to the object, false if they do not.
*/ */
public boolean checkPermissions (Subscriber sub) public boolean checkPermissions (Subscriber<?> sub)
{ {
if (_controller != null) { if (_controller != null) {
return _controller.allowSubscribe(this, sub); return _controller.allowSubscribe(this, sub);
@@ -814,7 +816,7 @@ public class DObject
* Calls by derived instances when a set remover method was called. * Calls by derived instances when a set remover method was called.
*/ */
protected <T extends DSet.Entry> void requestEntryRemove ( protected <T extends DSet.Entry> void requestEntryRemove (
String name, DSet<T> set, Comparable key) String name, DSet<T> set, Comparable<?> key)
{ {
// if we're on the authoritative server, we update the set immediately // if we're on the authoritative server, we update the set immediately
T oldEntry = null; T oldEntry = null;
@@ -913,7 +915,7 @@ public class DObject
protected transient boolean _deathWish = false; protected transient boolean _deathWish = false;
/** Maintains a mapping of sorted field arrays for each distributed object class. */ /** Maintains a mapping of sorted field arrays for each distributed object class. */
protected static HashMap<Class, Field[]> _ftable = new HashMap<Class, Field[]>(); protected static Map<Class<?>, Field[]> _ftable = Maps.newHashMap();
/** Used to sort and search {@link #_fields}. */ /** Used to sort and search {@link #_fields}. */
protected static final Comparator<Field> FIELD_COMP = new Comparator<Field>() { protected static final Comparator<Field> FIELD_COMP = new Comparator<Field>() {
@@ -63,7 +63,7 @@ public class DSet<E extends DSet.Entry>
* Each entry provide an associated key which is used to determine its uniqueness in the * Each entry provide an associated key which is used to determine its uniqueness in the
* set. See the {@link DSet} class documentation for further information. * set. See the {@link DSet} class documentation for further information.
*/ */
Comparable getKey (); Comparable<?> getKey ();
} }
/** /**
@@ -82,6 +82,17 @@ public class DSet<E extends DSet.Entry>
return new DSet<E>(source); return new DSet<E>(source);
} }
/**
* Compares the first comparable to the second. This is useful to avoid type safety warnings
* when dealing with the keys of {@link DSet.Entry} values.
*/
public static int compare (Comparable<?> c1, Comparable<?> c2)
{
@SuppressWarnings("unchecked") Comparable<Object> cc1 = (Comparable<Object>)c1;
@SuppressWarnings("unchecked") Comparable<Object> cc2 = (Comparable<Object>)c2;
return cc1.compareTo(cc2);
}
/** /**
* Creates a distributed set and populates it with values from the supplied iterator. This * Creates a distributed set and populates it with values from the supplied iterator. This
* should be done before the set is unleashed into the wild distributed object world because no * should be done before the set is unleashed into the wild distributed object world because no
@@ -161,7 +172,7 @@ public class DSet<E extends DSet.Entry>
* Returns true if an entry in the set has a key that <code>equals()</code> the supplied * Returns true if an entry in the set has a key that <code>equals()</code> the supplied
* key. Returns false otherwise. * key. Returns false otherwise.
*/ */
public boolean containsKey (Comparable key) public boolean containsKey (Comparable<?> key)
{ {
return get(key) != null; return get(key) != null;
} }
@@ -170,7 +181,7 @@ public class DSet<E extends DSet.Entry>
* Returns the entry that matches (<code>getKey().equals(key)</code>) the specified key or null * Returns the entry that matches (<code>getKey().equals(key)</code>) the specified key or null
* if no entry could be found that matches the key. * if no entry could be found that matches the key.
*/ */
public E get (Comparable key) public E get (Comparable<?> key)
{ {
// determine where we'll be adding the new element // determine where we'll be adding the new element
int eidx = ArrayUtil.binarySearch(_entries, 0, _size, new KeyWrapper(key), ENTRY_COMP); int eidx = ArrayUtil.binarySearch(_entries, 0, _size, new KeyWrapper(key), ENTRY_COMP);
@@ -325,7 +336,7 @@ public class DSet<E extends DSet.Entry>
* *
* @return the old matching entry if found and removed, null if not found. * @return the old matching entry if found and removed, null if not found.
*/ */
protected E removeKey (Comparable key) protected E removeKey (Comparable<?> key)
{ {
// don't fail, but generate a warning if we're passed a null key // don't fail, but generate a warning if we're passed a null key
if (key == null) { if (key == null) {
@@ -461,13 +472,13 @@ public class DSet<E extends DSet.Entry>
/** Used to search for keys. */ /** Used to search for keys. */
protected static class KeyWrapper implements DSet.Entry protected static class KeyWrapper implements DSet.Entry
{ {
public KeyWrapper (Comparable key) { public KeyWrapper (Comparable<?> key) {
_key = key; _key = key;
} }
public Comparable getKey () { public Comparable<?> getKey () {
return _key; return _key;
} }
protected Comparable _key; protected Comparable<?> _key;
} }
/** The entries of the set (in a sparse array). */ /** The entries of the set (in a sparse array). */
@@ -485,8 +496,7 @@ public class DSet<E extends DSet.Entry>
/** Used for lookups and to keep the set contents sorted on insertions. */ /** Used for lookups and to keep the set contents sorted on insertions. */
protected static Comparator<Entry> ENTRY_COMP = new Comparator<Entry>() { protected static Comparator<Entry> ENTRY_COMP = new Comparator<Entry>() {
public int compare (Entry e1, Entry e2) { public int compare (Entry e1, Entry e2) {
@SuppressWarnings("unchecked") int val = e1.getKey().compareTo(e2.getKey()); return DSet.compare(e1.getKey(), e2.getKey());
return val;
} }
}; };
} }
@@ -33,8 +33,8 @@ import static com.threerings.presents.Log.log;
/** /**
* Maps distributed object events to methods using reflection. * Maps distributed object events to methods using reflection.
*/ */
public class DynamicListener public class DynamicListener<T extends DSet.Entry>
implements AttributeChangeListener, ElementUpdateListener, SetListener implements AttributeChangeListener, ElementUpdateListener, SetListener<T>
{ {
/** /**
* Creates a listener that dynamically dispatches events on the supplied * Creates a listener that dynamically dispatches events on the supplied
@@ -70,21 +70,21 @@ public class DynamicListener
} }
// from interface SetListener // from interface SetListener
public void entryAdded (EntryAddedEvent event) public void entryAdded (EntryAddedEvent<T> event)
{ {
dispatchMethod(event.getName() + "Added", dispatchMethod(event.getName() + "Added",
new Object[] { event.getEntry() }); new Object[] { event.getEntry() });
} }
// from interface SetListener // from interface SetListener
public void entryUpdated (EntryUpdatedEvent event) public void entryUpdated (EntryUpdatedEvent<T> event)
{ {
dispatchMethod(event.getName() + "Updated", dispatchMethod(event.getName() + "Updated",
new Object[] { event.getEntry() }); new Object[] { event.getEntry() });
} }
// from interface SetListener // from interface SetListener
public void entryRemoved (EntryRemovedEvent event) public void entryRemoved (EntryRemovedEvent<T> event)
{ {
dispatchMethod(event.getName() + "Removed", dispatchMethod(event.getName() + "Removed",
new Object[] { event.getKey() }); new Object[] { event.getKey() });
@@ -120,7 +120,7 @@ public class DynamicListener
*/ */
protected Method resolveMethod (String name, Object[] arguments) protected Method resolveMethod (String name, Object[] arguments)
{ {
Class[] ptypes = new Class[arguments.length]; Class<?>[] ptypes = new Class<?>[arguments.length];
for (int ii = 0; ii < arguments.length; ii++) { for (int ii = 0; ii < arguments.length; ii++) {
ptypes[ii] = arguments[ii] == null ? ptypes[ii] = arguments[ii] == null ?
null : arguments[ii].getClass(); null : arguments[ii].getClass();
@@ -167,7 +167,7 @@ public class ElementUpdatedEvent extends NamedEvent
try { try {
// fetch the array field from the object // fetch the array field from the object
Field field = target.getClass().getField(_name); Field field = target.getClass().getField(_name);
Class ftype = field.getType(); Class<?> ftype = field.getType();
// sanity check // sanity check
if (!ftype.isArray()) { if (!ftype.isArray()) {
@@ -44,7 +44,7 @@ public class EntryRemovedEvent<T extends DSet.Entry> extends NamedEvent
* @param key the entry key that identifies the entry to remove. * @param key the entry key that identifies the entry to remove.
* @param oldEntry the previous value of the entry. * @param oldEntry the previous value of the entry.
*/ */
public EntryRemovedEvent (int targetOid, String name, Comparable key, T oldEntry) public EntryRemovedEvent (int targetOid, String name, Comparable<?> key, T oldEntry)
{ {
super(targetOid, name); super(targetOid, name);
_key = key; _key = key;
@@ -62,7 +62,7 @@ public class EntryRemovedEvent<T extends DSet.Entry> extends NamedEvent
/** /**
* Returns the key that identifies the entry that has been removed. * Returns the key that identifies the entry that has been removed.
*/ */
public Comparable getKey () public Comparable<?> getKey ()
{ {
return _key; return _key;
} }
@@ -115,7 +115,7 @@ public class EntryRemovedEvent<T extends DSet.Entry> extends NamedEvent
buf.append(", key=").append(_key); buf.append(", key=").append(_key);
} }
protected Comparable _key; protected Comparable<?> _key;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected transient T _oldEntry = (T)UNSET_OLD_ENTRY; protected transient T _oldEntry = (T)UNSET_OLD_ENTRY;
@@ -36,7 +36,7 @@ public class ClientInfo extends SimpleStreamableObject
public Name username; public Name username;
// documentation inherited from interface DSet.Entry // documentation inherited from interface DSet.Entry
public Comparable getKey () public Comparable<?> getKey ()
{ {
return username; return username;
} }
@@ -65,13 +65,13 @@ public class NodeObject extends DObject
public String type; public String type;
/** The resource identifier, which can be <code>null</code> for singleton resources. */ /** The resource identifier, which can be <code>null</code> for singleton resources. */
public Comparable id; public Comparable<?> id;
public Lock () public Lock ()
{ {
} }
public Lock (String type, Comparable id) public Lock (String type, Comparable<?> id)
{ {
this.type = type; this.type = type;
this.id = id; this.id = id;
@@ -84,12 +84,11 @@ public class NodeObject extends DObject
if (v1 != 0 || id == null) { if (v1 != 0 || id == null) {
return v1; return v1;
} }
@SuppressWarnings("unchecked") int v2 = id.compareTo(olock.id); return DSet.compare(id, olock.id);
return v2;
} }
// documentation inherited from interface DSet.Entry // documentation inherited from interface DSet.Entry
public Comparable getKey () public Comparable<?> getKey ()
{ {
return this; return this;
} }
@@ -197,7 +196,7 @@ public class NodeObject extends DObject
* the <code>clients</code> set. The set will not change until the * the <code>clients</code> set. The set will not change until the
* event is actually propagated through the system. * event is actually propagated through the system.
*/ */
public void removeFromClients (Comparable key) public void removeFromClients (Comparable<?> key)
{ {
requestEntryRemove(CLIENTS, clients, key); requestEntryRemove(CLIENTS, clients, key);
} }
@@ -225,8 +224,7 @@ public class NodeObject extends DObject
public void setClients (DSet<ClientInfo> value) public void setClients (DSet<ClientInfo> value)
{ {
requestAttributeChange(CLIENTS, value, this.clients); requestAttributeChange(CLIENTS, value, this.clients);
@SuppressWarnings("unchecked") DSet<ClientInfo> clone = DSet<ClientInfo> clone = (value == null) ? null : value.typedClone();
(value == null) ? null : value.typedClone();
this.clients = clone; this.clients = clone;
} }
@@ -245,7 +243,7 @@ public class NodeObject extends DObject
* the <code>locks</code> set. The set will not change until the * the <code>locks</code> set. The set will not change until the
* event is actually propagated through the system. * event is actually propagated through the system.
*/ */
public void removeFromLocks (Comparable key) public void removeFromLocks (Comparable<?> key)
{ {
requestEntryRemove(LOCKS, locks, key); requestEntryRemove(LOCKS, locks, key);
} }
@@ -273,8 +271,7 @@ public class NodeObject extends DObject
public void setLocks (DSet<NodeObject.Lock> value) public void setLocks (DSet<NodeObject.Lock> value)
{ {
requestAttributeChange(LOCKS, value, this.locks); requestAttributeChange(LOCKS, value, this.locks);
@SuppressWarnings("unchecked") DSet<NodeObject.Lock> clone = DSet<NodeObject.Lock> clone = (value == null) ? null : value.typedClone();
(value == null) ? null : value.typedClone();
this.locks = clone; this.locks = clone;
} }
@@ -47,7 +47,6 @@ public class PeerDispatcher extends InvocationDispatcher<PeerMarshaller>
return new PeerMarshaller(); return new PeerMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -989,7 +989,7 @@ public abstract class PeerManager
* Handles a lock in a state of resolution. * Handles a lock in a state of resolution.
*/ */
protected class LockHandler protected class LockHandler
implements SetListener implements SetListener<NodeObject.Lock>
{ {
/** Listeners waiting for resolution. */ /** Listeners waiting for resolution. */
public ResultListenerList<String> listeners = new ResultListenerList<String>(); public ResultListenerList<String> listeners = new ResultListenerList<String>();
@@ -1116,7 +1116,7 @@ public abstract class PeerManager
} }
// documentation inherited from interface SetListener // documentation inherited from interface SetListener
public void entryAdded (EntryAddedEvent event) public void entryAdded (EntryAddedEvent<NodeObject.Lock> event)
{ {
if (_acquire && event.getName().equals(NodeObject.LOCKS) && if (_acquire && event.getName().equals(NodeObject.LOCKS) &&
event.getEntry().equals(_lock)) { event.getEntry().equals(_lock)) {
@@ -1125,7 +1125,7 @@ public abstract class PeerManager
} }
// documentation inherited from interface SetListener // documentation inherited from interface SetListener
public void entryRemoved (EntryRemovedEvent event) public void entryRemoved (EntryRemovedEvent<NodeObject.Lock> event)
{ {
if (!_acquire && event.getName().equals(NodeObject.LOCKS) && if (!_acquire && event.getName().equals(NodeObject.LOCKS) &&
event.getOldEntry().equals(_lock)) { event.getOldEntry().equals(_lock)) {
@@ -1134,7 +1134,7 @@ public abstract class PeerManager
} }
// documentation inherited from interface SetListener // documentation inherited from interface SetListener
public void entryUpdated (EntryUpdatedEvent event) public void entryUpdated (EntryUpdatedEvent<NodeObject.Lock> event)
{ {
if (!_acquire && event.getName().equals(NodeObject.LOCKS) && if (!_acquire && event.getName().equals(NodeObject.LOCKS) &&
event.getEntry().equals(_lock)) { event.getEntry().equals(_lock)) {
@@ -52,13 +52,13 @@ public class PeerUtil
S createProviderProxy (Class<S> clazz, final T svc, final Client client) S createProviderProxy (Class<S> clazz, final T svc, final Client client)
{ {
return clazz.cast(Proxy.newProxyInstance( return clazz.cast(Proxy.newProxyInstance(
clazz.getClassLoader(), new Class[] { clazz }, clazz.getClassLoader(), new Class<?>[] { clazz },
new InvocationHandler() { new InvocationHandler() {
public Object invoke (Object proxy, Method method, Object[] args) public Object invoke (Object proxy, Method method, Object[] args)
throws Throwable { throws Throwable {
Method smethod = _pmethods.get(method); Method smethod = _pmethods.get(method);
if (smethod == null) { if (smethod == null) {
Class[] ptypes = method.getParameterTypes(); Class<?>[] ptypes = method.getParameterTypes();
ptypes[0] = Client.class; ptypes[0] = Client.class;
_pmethods.put(method, smethod = svc.getClass().getMethod( _pmethods.put(method, smethod = svc.getClass().getMethod(
method.getName(), ptypes)); method.getName(), ptypes));
@@ -196,7 +196,7 @@ public class InvocationManager
* @return the Class, or null if no dispatcher is registered with * @return the Class, or null if no dispatcher is registered with
* the specified code. * the specified code.
*/ */
public Class getDispatcherClass (int invCode) public Class<?> getDispatcherClass (int invCode)
{ {
Object dispatcher = _dispatchers.get(invCode); Object dispatcher = _dispatchers.get(invCode);
return (dispatcher == null) ? null : dispatcher.getClass(); return (dispatcher == null) ? null : dispatcher.getClass();
@@ -233,7 +233,7 @@ public class InvocationManager
} }
// look up the dispatcher // look up the dispatcher
InvocationDispatcher disp = _dispatchers.get(invCode); InvocationDispatcher<?> disp = _dispatchers.get(invCode);
if (disp == null) { if (disp == null) {
log.info("Received invocation request but dispatcher " + log.info("Received invocation request but dispatcher " +
"registration was already cleared [code=" + invCode + "registration was already cleared [code=" + invCode +
@@ -317,7 +317,7 @@ public class InvocationManager
protected PresentsDObjectMgr _omgr; protected PresentsDObjectMgr _omgr;
/** A table of invocation dispatchers each mapped by a unique code. */ /** A table of invocation dispatchers each mapped by a unique code. */
protected IntMap<InvocationDispatcher> _dispatchers = IntMaps.newHashIntMap(); protected IntMap<InvocationDispatcher<?>> _dispatchers = IntMaps.newHashIntMap();
/** Maps bootstrap group to lists of services to be provided to clients at boot time. */ /** Maps bootstrap group to lists of services to be provided to clients at boot time. */
protected Map<String, List<InvocationMarshaller>> _bootlists = Maps.newHashMap(); protected Map<String, List<InvocationMarshaller>> _bootlists = Maps.newHashMap();
@@ -90,7 +90,7 @@ public class PresentsClient
* *
* @param rl when this method is finished with its business and the old client object can * @param rl when this method is finished with its business and the old client object can
* be destroyed, the result listener should be called. */ * be destroyed, the result listener should be called. */
void changeReported (ClientObject newObji, ResultListener rl); void changeReported (ClientObject newObji, ResultListener<Void> rl);
/** Called when the user change is completed, the old client object is destroyed and all /** Called when the user change is completed, the old client object is destroyed and all
* updates are committed. */ * updates are committed. */
@@ -210,8 +210,8 @@ public class PresentsClient
// let the caller know that we've got some new business // let the caller know that we've got some new business
if (ucl != null) { if (ucl != null) {
ucl.changeReported(clobj, new ResultListener() { ucl.changeReported(clobj, new ResultListener<Void>() {
public void requestCompleted (Object result) { public void requestCompleted (Void result) {
finishResolved(username, clobj); finishResolved(username, clobj);
} }
public void requestFailed (Exception cause) { public void requestFailed (Exception cause) {
@@ -402,7 +402,7 @@ public class PresentsDObjectMgr
// if this object has any oid list fields that are still referencing other objects, we need // if this object has any oid list fields that are still referencing other objects, we need
// to clear out those references // to clear out those references
Class oclass = target.getClass(); Class<?> oclass = target.getClass();
Field[] fields = oclass.getFields(); Field[] fields = oclass.getFields();
for (int f = 0; f < fields.length; f++) { for (int f = 0; f < fields.length; f++) {
Field field = fields[f]; Field field = fields[f];
@@ -626,7 +626,7 @@ public class PresentsDObjectMgr
cname = StringUtil.shortClassName(ival); cname = StringUtil.shortClassName(ival);
} else if (unit instanceof InvocationRequestEvent) { } else if (unit instanceof InvocationRequestEvent) {
InvocationRequestEvent ire = (InvocationRequestEvent)unit; InvocationRequestEvent ire = (InvocationRequestEvent)unit;
Class c = _invmgr.getDispatcherClass(ire.getInvCode()); Class<?> c = _invmgr.getDispatcherClass(ire.getInvCode());
cname = (c == null) ? "dobj.InvocationRequestEvent:(no longer registered)" : cname = (c == null) ? "dobj.InvocationRequestEvent:(no longer registered)" :
StringUtil.shortClassName(c) + ":" + ire.getMethodId(); StringUtil.shortClassName(c) + ":" + ire.getMethodId();
} else { } else {
@@ -645,7 +645,7 @@ public class PresentsDObjectMgr
*/ */
protected void processCompoundEvent (CompoundEvent event) protected void processCompoundEvent (CompoundEvent event)
{ {
List events = event.getEvents(); List<DEvent> events = event.getEvents();
int ecount = events.size(); int ecount = events.size();
// look up the target object // look up the target object
@@ -657,7 +657,7 @@ public class PresentsDObjectMgr
// check the permissions on all of the events // check the permissions on all of the events
for (int ii = 0; ii < ecount; ii++) { for (int ii = 0; ii < ecount; ii++) {
DEvent sevent = (DEvent)events.get(ii); DEvent sevent = events.get(ii);
if (!target.checkPermissions(sevent)) { if (!target.checkPermissions(sevent)) {
log.warning("Event failed permissions check [event=" + sevent + log.warning("Event failed permissions check [event=" + sevent +
", target=" + target + "]."); ", target=" + target + "].");
@@ -667,7 +667,7 @@ public class PresentsDObjectMgr
// dispatch the events // dispatch the events
for (int ii = 0; ii < ecount; ii++) { for (int ii = 0; ii < ecount; ii++) {
dispatchEvent((DEvent)events.get(ii), target); dispatchEvent(events.get(ii), target);
} }
// always notify proxies of compound events // always notify proxies of compound events
@@ -810,7 +810,7 @@ public class PresentsDObjectMgr
*/ */
protected void registerEventHelpers () protected void registerEventHelpers ()
{ {
Class[] ptypes = new Class[] { DEvent.class, DObject.class }; Class<?>[] ptypes = new Class<?>[] { DEvent.class, DObject.class };
Method method; Method method;
try { try {
@@ -1030,7 +1030,7 @@ public class PresentsDObjectMgr
protected Stats _recent = new Stats(), _current = _recent; protected Stats _recent = new Stats(), _current = _recent;
/** Maps event classes to helpers that perform additional processing for particular events. */ /** Maps event classes to helpers that perform additional processing for particular events. */
protected Map<Class, Method> _helpers = Maps.newHashMap(); protected Map<Class<?>, Method> _helpers = Maps.newHashMap();
/** Used to resolve unit names when profiling. Injected by the invmgr when it's created. */ /** Used to resolve unit names when profiling. Injected by the invmgr when it's created. */
protected InvocationManager _invmgr; protected InvocationManager _invmgr;
@@ -78,7 +78,7 @@ public class PresentsInvoker extends Invoker
for (Object key : _tracker.keySet()) { for (Object key : _tracker.keySet()) {
UnitProfile profile = _tracker.get(key); UnitProfile profile = _tracker.get(key);
if (key instanceof Class) { if (key instanceof Class) {
key = StringUtil.shortClassName((Class)key); key = StringUtil.shortClassName((Class<?>)key);
} }
buf.append(" ").append(key).append(" "); buf.append(" ").append(key).append(" ");
buf.append(profile).append("\n"); buf.append(profile).append("\n");
@@ -44,7 +44,7 @@ public class PresentsObjectAccess
public static AccessController DEFAULT = new AccessController() public static AccessController DEFAULT = new AccessController()
{ {
// documentation inherited from interface // documentation inherited from interface
public boolean allowSubscribe (DObject object, Subscriber subscriber) public boolean allowSubscribe (DObject object, Subscriber<?> subscriber)
{ {
// allow anyone to subscribe // allow anyone to subscribe
return true; return true;
@@ -70,12 +70,13 @@ public class PresentsObjectAccess
public static AccessController CLIENT = new AccessController() public static AccessController CLIENT = new AccessController()
{ {
// documentation inherited from interface // documentation inherited from interface
public boolean allowSubscribe (DObject object, Subscriber sub) public boolean allowSubscribe (DObject object, Subscriber<?> sub)
{ {
boolean allowed = true; boolean allowed = true;
// if the subscriber is a client, ensure that they are this same user // if the subscriber is a client, ensure that they are this same user
if (sub instanceof PresentsClient) { if (PresentsClient.class.isInstance(sub)) {
allowed = ((PresentsClient)sub).getClientObject() == object; @SuppressWarnings("unchecked") PresentsClient client = (PresentsClient)sub;
allowed = (client.getClientObject() == object);
if (!allowed) { if (!allowed) {
log.warning("Refusing ClientObject subscription request " + log.warning("Refusing ClientObject subscription request " +
"[obj=" + ((ClientObject)object).who() + ", sub=" + sub + "]."); "[obj=" + ((ClientObject)object).who() + ", sub=" + sub + "].");
@@ -81,7 +81,7 @@ public class PresentsServer
if (testmod != null) { if (testmod != null) {
try { try {
log.info("Invoking test module [mod=" + testmod + "]."); log.info("Invoking test module [mod=" + testmod + "].");
Class tmclass = Class.forName(testmod); Class<?> tmclass = Class.forName(testmod);
Runnable trun = (Runnable)tmclass.newInstance(); Runnable trun = (Runnable)tmclass.newInstance();
trun.run(); trun.run();
} catch (Exception e) { } catch (Exception e) {
@@ -45,7 +45,6 @@ public class TimeBaseDispatcher extends InvocationDispatcher<TimeBaseMarshaller>
return new TimeBaseMarshaller(); return new TimeBaseMarshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -184,7 +184,7 @@ public class ActionScriptSource
return builder.toString(); return builder.toString();
} }
public static String createActionScriptDeclaration (Constructor ctor, boolean needsNoArg) public static String createActionScriptDeclaration (Constructor<?> ctor, boolean needsNoArg)
{ {
int mods = ctor.getModifiers(); int mods = ctor.getModifiers();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@@ -262,7 +262,7 @@ public class ActionScriptSource
return builder.toString(); return builder.toString();
} }
public static String toActionScriptType (Class type, boolean isField) public static String toActionScriptType (Class<?> type, boolean isField)
{ {
if (type.isArray()) { if (type.isArray()) {
if (Byte.TYPE.equals(type.getComponentType())) { if (Byte.TYPE.equals(type.getComponentType())) {
@@ -294,11 +294,11 @@ public class ActionScriptSource
return toSimpleName(type.getName()); return toSimpleName(type.getName());
} }
public ActionScriptSource (Class jclass) public ActionScriptSource (Class<?> jclass)
{ {
packageName = jclass.getPackage().getName(); packageName = jclass.getPackage().getName();
className = jclass.getName().substring(packageName.length()+1); className = jclass.getName().substring(packageName.length()+1);
Class sclass = jclass.getSuperclass(); Class<?> sclass = jclass.getSuperclass();
if (sclass != null && !sclass.getName().equals("java.lang.Object")) { if (sclass != null && !sclass.getName().equals("java.lang.Object")) {
superClassName = toSimpleName(sclass.getName()); superClassName = toSimpleName(sclass.getName());
} }
@@ -306,7 +306,7 @@ public class ActionScriptSource
// note our implemented interfaces // note our implemented interfaces
ArrayList<String> ifaces = new ArrayList<String>(); ArrayList<String> ifaces = new ArrayList<String>();
for (Class iclass : jclass.getInterfaces()) { for (Class<?> iclass : jclass.getInterfaces()) {
// we cannot use the FooCodes interface pattern in ActionScript so we just nix it // we cannot use the FooCodes interface pattern in ActionScript so we just nix it
if (iclass.getName().endsWith("Codes")) { if (iclass.getName().endsWith("Codes")) {
continue; continue;
@@ -95,7 +95,7 @@ public class GenActionScriptBundlesTask extends Task
if (true) { if (true) {
// create an array with all the values, then populate in a loop // create an array with all the values, then populate in a loop
out.println(" var data :Array = ["); out.println(" var data :Array = [");
for (Map.Entry entry : props.entrySet()) { for (Map.Entry<Object, Object> entry : props.entrySet()) {
String key = saveConvert((String) entry.getKey()); String key = saveConvert((String) entry.getKey());
String val = saveConvert((String) entry.getValue()); String val = saveConvert((String) entry.getValue());
out.println(" \"" + key + "\", \"" + val + "\","); out.println(" \"" + key + "\", \"" + val + "\",");
@@ -110,7 +110,7 @@ public class GenActionScriptBundlesTask extends Task
// alternate impl: just set each value directly. For non-trivial // alternate impl: just set each value directly. For non-trivial
// resource bundles, this generates a larger class after compilation // resource bundles, this generates a larger class after compilation
out.println(" var o :Object = new Object();"); out.println(" var o :Object = new Object();");
for (Map.Entry entry : props.entrySet()) { for (Map.Entry<Object, Object> entry : props.entrySet()) {
String key = saveConvert((String) entry.getKey()); String key = saveConvert((String) entry.getKey());
String val = saveConvert((String) entry.getValue()); String val = saveConvert((String) entry.getValue());
out.println(" o[\"" + key + "\"] = \"" + val + "\";"); out.println(" o[\"" + key + "\"] = \"" + val + "\";");
@@ -246,7 +246,7 @@ public class GenActionScriptTask extends Task
return !Modifier.isStatic(mods) && !Modifier.isTransient(mods); return !Modifier.isStatic(mods) && !Modifier.isTransient(mods);
} }
protected String toReadObject (Class type) protected String toReadObject (Class<?> type)
{ {
if (type.equals(String.class)) { if (type.equals(String.class)) {
return "(ins.readField(String) as String)"; return "(ins.readField(String) as String)";
@@ -296,7 +296,7 @@ public class GenActionScriptTask extends Task
} }
} }
protected String toWriteObject (Class type, String name) protected String toWriteObject (Class<?> type, String name)
{ {
if (type.equals(Integer.class)) { if (type.equals(Integer.class)) {
return "writeObject(new Integer(" + name + "))"; return "writeObject(new Integer(" + name + "))";
@@ -142,7 +142,7 @@ public class GenDObjectTask extends Task
} }
/** Processes a resolved distributed object class instance. */ /** Processes a resolved distributed object class instance. */
protected void processObject (File source, Class oclass) protected void processObject (File source, Class<?> oclass)
{ {
// make sure we extend distributed object // make sure we extend distributed object
if (!_doclass.isAssignableFrom(oclass) || _doclass.equals(oclass)) { if (!_doclass.isAssignableFrom(oclass) || _doclass.equals(oclass)) {
@@ -226,8 +226,7 @@ public class GenDObjectTask extends Task
if (t instanceof ParameterizedType) { if (t instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType)t; ParameterizedType pt = (ParameterizedType)t;
if (pt.getActualTypeArguments().length > 0) { if (pt.getActualTypeArguments().length > 0) {
ctx.put("etype", GenUtil.simpleName( ctx.put("etype", GenUtil.simpleName(pt.getActualTypeArguments()[0]));
(Class<?>)pt.getActualTypeArguments()[0]));
} }
} else { } else {
ctx.put("etype", "DSet.Entry"); ctx.put("etype", "DSet.Entry");
@@ -46,7 +46,7 @@ import com.threerings.presents.server.InvocationSender;
public class GenReceiverTask extends InvocationTask public class GenReceiverTask extends InvocationTask
{ {
@Override @Override
protected void processService (File source, Class receiver) protected void processService (File source, Class<?> receiver)
{ {
System.out.println("Processing " + receiver.getName() + "..."); System.out.println("Processing " + receiver.getName() + "...");
String rname = receiver.getName(); String rname = receiver.getName();
@@ -92,7 +92,7 @@ public class GenReceiverTask extends InvocationTask
} }
protected void generateSender (File source, String rname, String rpackage, protected void generateSender (File source, String rname, String rpackage,
List methods, Iterator<String> imports) List<?> methods, Iterator<String> imports)
{ {
String name = StringUtil.replace(rname, "Receiver", ""); String name = StringUtil.replace(rname, "Receiver", "");
String spackage = StringUtil.replace(rpackage, ".client", ".server"); String spackage = StringUtil.replace(rpackage, ".client", ".server");
@@ -130,8 +130,7 @@ public class GenReceiverTask extends InvocationTask
} }
protected void generateDecoder ( protected void generateDecoder (
File source, String rname, String rpackage, List methods, File source, String rname, String rpackage, List<?> methods, Iterator<String> imports)
Iterator<String> imports)
{ {
String name = StringUtil.replace(rname, "Receiver", ""); String name = StringUtil.replace(rname, "Receiver", "");
@@ -57,7 +57,7 @@ public class GenServiceTask extends InvocationTask
/** Used to keep track of custom InvocationListener derivations. */ /** Used to keep track of custom InvocationListener derivations. */
public class ServiceListener implements Comparable<ServiceListener> public class ServiceListener implements Comparable<ServiceListener>
{ {
public Class listener; public Class<?> listener;
public ComparableArrayList<ServiceMethod> methods = public ComparableArrayList<ServiceMethod> methods =
new ComparableArrayList<ServiceMethod>(); new ComparableArrayList<ServiceMethod>();
@@ -65,7 +65,7 @@ public class GenServiceTask extends InvocationTask
/** Contains all imports required for the parameters of the methods in this listener. */ /** Contains all imports required for the parameters of the methods in this listener. */
public ImportSet imports = new ImportSet(); public ImportSet imports = new ImportSet();
public ServiceListener (Class service, Class listener) public ServiceListener (Class<?> service, Class<?> listener)
{ {
this.listener = listener; this.listener = listener;
Method[] methdecls = listener.getDeclaredMethods(); Method[] methdecls = listener.getDeclaredMethods();
@@ -141,7 +141,7 @@ public class GenServiceTask extends InvocationTask
// documentation inherited // documentation inherited
@Override @Override
protected void processService (File source, Class service) protected void processService (File source, Class<?> service)
{ {
System.out.println("Processing " + service.getName() + "..."); System.out.println("Processing " + service.getName() + "...");
@@ -303,7 +303,7 @@ public class GenServiceTask extends InvocationTask
// ----------- Part III - as listener marshallers // ----------- Part III - as listener marshallers
Class imlm = InvocationMarshaller.ListenerMarshaller.class; Class<?> imlm = InvocationMarshaller.ListenerMarshaller.class;
// now generate ActionScript versions of our listener marshallers // now generate ActionScript versions of our listener marshallers
// because those have to be in separate files // because those have to be in separate files
@@ -401,7 +401,7 @@ public class GenServiceTask extends InvocationTask
// ----------- Part V - as service listeners // ----------- Part V - as service listeners
Class isil = InvocationService.InvocationListener.class; Class<?> isil = InvocationService.InvocationListener.class;
// also generate ActionScript versions of any inner listener // also generate ActionScript versions of any inner listener
// interfaces because those have to be in separate files // interfaces because those have to be in separate files
@@ -585,7 +585,7 @@ public class GenServiceTask extends InvocationTask
/** Rolls up everything needed for the generate* methods. */ /** Rolls up everything needed for the generate* methods. */
protected class ServiceDescription protected class ServiceDescription
{ {
public Class service; public Class<?> service;
public String sname; public String sname;
public String spackage; public String spackage;
public ImportSet imports = new ImportSet(); public ImportSet imports = new ImportSet();
@@ -594,7 +594,7 @@ public class GenServiceTask extends InvocationTask
public ComparableArrayList<ServiceListener> listeners = public ComparableArrayList<ServiceListener> listeners =
new ComparableArrayList<ServiceListener>(); new ComparableArrayList<ServiceListener>();
public ServiceDescription (Class serviceClass) public ServiceDescription (Class<?> serviceClass)
{ {
service = serviceClass; service = serviceClass;
sname = service.getSimpleName(); sname = service.getSimpleName();
@@ -611,7 +611,7 @@ public class GenServiceTask extends InvocationTask
continue; continue;
} }
// check this method for custom listener declarations // check this method for custom listener declarations
Class[] args = m.getParameterTypes(); Class<?>[] args = m.getParameterTypes();
for (int aa = 0; aa < args.length; aa++) { for (int aa = 0; aa < args.length; aa++) {
if (_ilistener.isAssignableFrom(args[aa]) && if (_ilistener.isAssignableFrom(args[aa]) &&
GenUtil.simpleName(args[aa]).startsWith(sname + ".")) { GenUtil.simpleName(args[aa]).startsWith(sname + ".")) {
@@ -111,7 +111,7 @@ public class GenStreamableTask extends Task
StringBuffer writebuf = new StringBuffer(WRITE_OPEN); StringBuffer writebuf = new StringBuffer(WRITE_OPEN);
// see if our parent also implements Streamable // see if our parent also implements Streamable
Class supster = sclass.getSuperclass(); Class<?> supster = sclass.getSuperclass();
do { do {
if (isStreamableClass(supster)) { if (isStreamableClass(supster)) {
readbuf.append(" super.readObject(ins);\n"); readbuf.append(" super.readObject(ins);\n");
@@ -174,9 +174,9 @@ public class GenStreamableTask extends Task
} }
} }
protected boolean isStreamableClass (Class clazz) protected boolean isStreamableClass (Class<?> clazz)
{ {
for (Class iface : clazz.getInterfaces()) { for (Class<?> iface : clazz.getInterfaces()) {
if (Streamable.class.equals(iface)) { if (Streamable.class.equals(iface)) {
return !SimpleStreamableObject.class.equals(clazz); return !SimpleStreamableObject.class.equals(clazz);
} }
@@ -53,7 +53,7 @@ public class GenUtil extends com.samskivert.util.GenUtil
public static String simpleASName (Class<?> clazz) public static String simpleASName (Class<?> clazz)
{ {
if (clazz.isArray()) { if (clazz.isArray()) {
Class compoType = clazz.getComponentType(); Class<?> compoType = clazz.getComponentType();
if (Byte.TYPE.equals(compoType)) { if (Byte.TYPE.equals(compoType)) {
return "ByteArray"; return "ByteArray";
} else if (Object.class.equals(compoType)) { } else if (Object.class.equals(compoType)) {
@@ -51,7 +51,7 @@ public class ImportSet
* Adds the given class' name to the set of imports. * Adds the given class' name to the set of imports.
* @param clazz the class to add * @param clazz the class to add
*/ */
public void add (Class clazz) public void add (Class<?> clazz)
{ {
_imports.add(clazz.getName()); _imports.add(clazz.getName());
} }
@@ -61,7 +61,7 @@ public abstract class InvocationTask extends Task
{ {
public int index; public int index;
public Class listener; public Class<?> listener;
public ListenerArgument (int index, Class<?> listener) public ListenerArgument (int index, Class<?> listener)
{ {
@@ -274,7 +274,7 @@ public abstract class InvocationTask extends Task
protected String unboxArgument (Type type, int index, boolean listenerMode) protected String unboxArgument (Type type, int index, boolean listenerMode)
{ {
if (listenerMode && (type instanceof Class) && if (listenerMode && (type instanceof Class) &&
_ilistener.isAssignableFrom((Class)type)) { _ilistener.isAssignableFrom((Class<?>)type)) {
return "listener" + index; return "listener" + index;
} else { } else {
return GenUtil.unboxArgument(type, "args[" + index + "]"); return GenUtil.unboxArgument(type, "args[" + index + "]");
@@ -385,7 +385,7 @@ public abstract class InvocationTask extends Task
} }
/** Processes a resolved invocation service class instance. */ /** Processes a resolved invocation service class instance. */
protected abstract void processService (File source, Class service); protected abstract void processService (File source, Class<?> service);
protected void writeFile (String path, String data) protected void writeFile (String path, String data)
throws IOException throws IOException
@@ -24,7 +24,6 @@ public class ${name}Dispatcher extends InvocationDispatcher<${name}Marshaller>
return new ${name}Marshaller(); return new ${name}Marshaller();
} }
@SuppressWarnings("unchecked")
@Override // documentation inherited @Override // documentation inherited
public void dispatchRequest ( public void dispatchRequest (
ClientObject source, int methodId, Object[] args) ClientObject source, int methodId, Object[] args)
@@ -13,7 +13,7 @@
* the <code>$field</code> set. The set will not change until the * the <code>$field</code> set. The set will not change until the
* event is actually propagated through the system. * event is actually propagated through the system.
*/ */
public void removeFrom$upfield (Comparable key) public void removeFrom$upfield (Comparable<?> key)
{ {
requestEntryRemove($capfield, $field, key); requestEntryRemove($capfield, $field, key);
} }
@@ -41,7 +41,6 @@
public void set$upfield ($type value) public void set$upfield ($type value)
{ {
requestAttributeChange($capfield, value, this.$field); requestAttributeChange($capfield, value, this.$field);
@SuppressWarnings("unchecked") $type clone = $type clone = $clonefield;
$clonefield;
this.$field = clone; this.$field = clone;
} }
@@ -45,7 +45,7 @@ public class ClassUtil
*/ */
public static Method getMethod (String name, Object target, Map<String, Method> cache) public static Method getMethod (String name, Object target, Map<String, Method> cache)
{ {
Class tclass = target.getClass(); Class<?> tclass = target.getClass();
String key = tclass.getName() + ":" + name; String key = tclass.getName() + ":" + name;
Method method = cache.get(key); Method method = cache.get(key);
@@ -71,7 +71,7 @@ public class ClassUtil
*/ */
public static Method getMethod (String name, Object target, Object[] args) public static Method getMethod (String name, Object target, Object[] args)
{ {
Class tclass = target.getClass(); Class<?> tclass = target.getClass();
Method meth = null; Method meth = null;
try { try {
@@ -98,7 +98,7 @@ public class ClassUtil
* @return the method with the specified name or null if no method with that name could be * @return the method with the specified name or null if no method with that name could be
* found. * found.
*/ */
public static Method findMethod (Class clazz, String name) public static Method findMethod (Class<?> clazz, String name)
{ {
Method[] methods = clazz.getMethods(); Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++) { for (int i = 0; i < methods.length; i++) {
@@ -59,7 +59,7 @@ public class DatagramSequencer
_uout.writeInt(_lastReceived); _uout.writeInt(_lastReceived);
// make sure the mapped class set is clear // make sure the mapped class set is clear
Set<Class> mappedClasses = _uout.getMappedClasses(); Set<Class<?>> mappedClasses = _uout.getMappedClasses();
mappedClasses.clear(); mappedClasses.clear();
// write the object // write the object
@@ -69,7 +69,7 @@ public class DatagramSequencer
if (mappedClasses.isEmpty()) { if (mappedClasses.isEmpty()) {
mappedClasses = null; mappedClasses = null;
} else { } else {
_uout.setMappedClasses(new HashSet<Class>()); _uout.setMappedClasses(new HashSet<Class<?>>());
} }
// record the transmission // record the transmission
@@ -123,9 +123,9 @@ public class DatagramSequencer
/** The set of classes for which mappings were included in the datagram (or /** The set of classes for which mappings were included in the datagram (or
* <code>null</code> for none). */ * <code>null</code> for none). */
public Set<Class> mappedClasses; public Set<Class<?>> mappedClasses;
public SendRecord (int number, Set<Class> mappedClasses) public SendRecord (int number, Set<Class<?>> mappedClasses)
{ {
this.number = number; this.number = number;
this.mappedClasses = mappedClasses; this.mappedClasses = mappedClasses;
+2 -2
View File
@@ -113,8 +113,8 @@ public class Name extends SimpleStreamableObject
public boolean equals (Object other) public boolean equals (Object other)
{ {
if (other != null) { if (other != null) {
Class c = getClass(); Class<?> c = getClass();
Class oc = other.getClass(); Class<?> oc = other.getClass();
// we have to be of the same derived class but we don't want to // we have to be of the same derived class but we don't want to
// wig out if the classes were loaded from different class loaders // wig out if the classes were loaded from different class loaders
if (c == oc || c.getName().equals(oc.getName())) { if (c == oc || c.getName().equals(oc.getName())) {
@@ -70,7 +70,7 @@ public class StreamableEnumSet<E extends Enum<E>> extends AbstractSet<E>
public static <E extends Enum<E>> StreamableEnumSet<E> copyOf (Collection<E> s) public static <E extends Enum<E>> StreamableEnumSet<E> copyOf (Collection<E> s)
{ {
if (s instanceof StreamableEnumSet) { if (s instanceof StreamableEnumSet) {
@SuppressWarnings("unchecked") StreamableEnumSet<E> set = (StreamableEnumSet<E>)s; StreamableEnumSet<E> set = (StreamableEnumSet<E>)s;
return copyOf(set); return copyOf(set);
} }
if (s.isEmpty()) { if (s.isEmpty()) {
@@ -197,7 +197,7 @@ public class StreamableEnumSet<E extends Enum<E>> extends AbstractSet<E>
if (!_elementType.isInstance(o)) { if (!_elementType.isInstance(o)) {
return false; return false;
} }
int ordinal = ((Enum)o).ordinal(); int ordinal = ((Enum<?>)o).ordinal();
int idx = ordinal >> 3, mask = 1 << (ordinal & 0x07); int idx = ordinal >> 3, mask = 1 << (ordinal & 0x07);
return (_contents[idx] & mask) != 0; return (_contents[idx] & mask) != 0;
} }
@@ -222,7 +222,7 @@ public class StreamableEnumSet<E extends Enum<E>> extends AbstractSet<E>
if (!_elementType.isInstance(o)) { if (!_elementType.isInstance(o)) {
return false; return false;
} }
int ordinal = ((Enum)o).ordinal(); int ordinal = ((Enum<?>)o).ordinal();
int idx = ordinal >> 3, mask = 1 << (ordinal & 0x07); int idx = ordinal >> 3, mask = 1 << (ordinal & 0x07);
if ((_contents[idx] & mask) != 0) { if ((_contents[idx] & mask) != 0) {
_contents[idx] &= ~mask; _contents[idx] &= ~mask;
@@ -22,7 +22,6 @@
package com.threerings.util; package com.threerings.util;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import com.samskivert.util.HashIntMap; import com.samskivert.util.HashIntMap;
@@ -66,8 +65,7 @@ public class StreamableHashIntMap<V> extends HashIntMap<V>
{ {
int ecount = size(); int ecount = size();
out.writeInt(ecount); out.writeInt(ecount);
for (Iterator iter = intEntrySet().iterator(); iter.hasNext(); ) { for (IntEntry<V> entry : intEntrySet()) {
IntEntry entry = (IntEntry) iter.next();
out.writeInt(entry.getIntKey()); out.writeInt(entry.getIntKey());
out.writeObject(entry.getValue()); out.writeObject(entry.getValue());
} }
@@ -22,7 +22,6 @@
package com.threerings.util; package com.threerings.util;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import com.samskivert.util.IntIntMap; import com.samskivert.util.IntIntMap;
@@ -65,8 +64,7 @@ public class StreamableIntIntMap extends IntIntMap
{ {
int ecount = size(); int ecount = size();
out.writeInt(ecount); out.writeInt(ecount);
for (Iterator itr = entrySet().iterator(); itr.hasNext(); ) { for (IntIntEntry entry : entrySet()) {
IntIntEntry entry = (IntIntEntry) itr.next();
out.writeInt(entry.getIntKey()); out.writeInt(entry.getIntKey());
out.writeInt(entry.getIntValue()); out.writeInt(entry.getIntValue());
} }
@@ -21,9 +21,10 @@
package com.threerings.util; package com.threerings.util;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.common.collect.Maps;
import com.samskivert.util.Tuple; import com.samskivert.util.Tuple;
import static com.threerings.NaryaLog.log; import static com.threerings.NaryaLog.log;
@@ -56,7 +57,7 @@ public class TrackedObject
/** Records that this object came into existence. */ /** Records that this object came into existence. */
protected final void incrementInstanceCount () protected final void incrementInstanceCount ()
{ {
Class clazz = getClass(); Class<?> clazz = getClass();
synchronized (_map) { synchronized (_map) {
int[] count = _map.get(clazz); int[] count = _map.get(clazz);
if (count == null) { if (count == null) {
@@ -71,7 +72,7 @@ public class TrackedObject
protected void finalize () protected void finalize ()
throws Throwable throws Throwable
{ {
Class clazz = getClass(); Class<?> clazz = getClass();
synchronized (_map) { synchronized (_map) {
int[] count = _map.get(clazz); int[] count = _map.get(clazz);
if (count != null) { if (count != null) {
@@ -90,23 +91,23 @@ public class TrackedObject
* instances and an <code>int[]</code> array that represent the number * instances and an <code>int[]</code> array that represent the number
* of outstanding instance of all {@link TrackedObject}s in the VM. * of outstanding instance of all {@link TrackedObject}s in the VM.
*/ */
public static Tuple<Class[], int[]> getSnapshot () public static Tuple<Class<?>[], int[]> getSnapshot ()
{ {
Class[] classes = null; Class<?>[] classes = null;
int[] counts = null; int[] counts = null;
synchronized (_map) { synchronized (_map) {
classes = new Class[_map.size()]; classes = new Class[_map.size()];
counts = new int[_map.size()]; counts = new int[_map.size()];
int idx = 0; int idx = 0;
for (Map.Entry<Class, int[]> entry : _map.entrySet()) { for (Map.Entry<Class<?>, int[]> entry : _map.entrySet()) {
classes[idx] = entry.getKey(); classes[idx] = entry.getKey();
counts[idx] = entry.getValue()[0]; counts[idx] = entry.getValue()[0];
idx++; idx++;
} }
} }
return new Tuple<Class[], int[]>(classes, counts); return new Tuple<Class<?>[], int[]>(classes, counts);
} }
/** Tracks a mapping from {@link Class} object to active count. */ /** Tracks a mapping from {@link Class} object to active count. */
protected static HashMap<Class, int[]> _map = new HashMap<Class, int[]>(); protected static Map<Class<?>, int[]> _map = Maps.newHashMap();
} }
@@ -38,7 +38,7 @@ public class DSetTest extends TestCase
_value = new Integer(value); _value = new Integer(value);
} }
public Comparable getKey () public Comparable<?> getKey ()
{ {
return _value; return _value;
} }