Handle parameterized types in invocation services and receivers.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6232 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2010-10-23 19:37:51 +00:00
parent a5c9acf288
commit e0dfddb46b
3 changed files with 21 additions and 1 deletions
@@ -45,4 +45,13 @@ public abstract class InvocationDecoder
log.warning("Requested to dispatch unknown method", "receiver", receiver,
"methodId", methodId, "args", args);
}
/**
* Performs type casts in a way that works for parameterized types as well as simple types.
*/
@SuppressWarnings("unchecked")
protected <T> T cast (Object value)
{
return (T)value;
}
}
@@ -49,4 +49,13 @@ public abstract class InvocationDispatcher<T extends InvocationMarshaller>
log.warning("Requested to dispatch unknown method", "provider", provider,
"sourceOid", source.getOid(), "methodId", methodId, "args", args);
}
/**
* Performs type casts in a way that works for parameterized types as well as simple types.
*/
@SuppressWarnings("unchecked")
protected <T> T cast (Object value)
{
return (T)value;
}
}
@@ -133,8 +133,10 @@ public class GenUtil extends com.samskivert.util.GenUtil
return "((Double)" + name + ").doubleValue()";
} else if (Object.class.equals(type)) {
return name; // no need to cast object
} else {
} else if (type instanceof Class<?>) {
return "(" + simpleName(type) + ")" + name;
} else {
return "this.<" + simpleName(type) + ">cast(" + name + ")";
}
}