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:
@@ -45,4 +45,13 @@ public abstract class InvocationDecoder
|
|||||||
log.warning("Requested to dispatch unknown method", "receiver", receiver,
|
log.warning("Requested to dispatch unknown method", "receiver", receiver,
|
||||||
"methodId", methodId, "args", args);
|
"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,
|
log.warning("Requested to dispatch unknown method", "provider", provider,
|
||||||
"sourceOid", source.getOid(), "methodId", methodId, "args", args);
|
"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()";
|
return "((Double)" + name + ").doubleValue()";
|
||||||
} else if (Object.class.equals(type)) {
|
} else if (Object.class.equals(type)) {
|
||||||
return name; // no need to cast object
|
return name; // no need to cast object
|
||||||
} else {
|
} else if (type instanceof Class<?>) {
|
||||||
return "(" + simpleName(type) + ")" + name;
|
return "(" + simpleName(type) + ")" + name;
|
||||||
|
} else {
|
||||||
|
return "this.<" + simpleName(type) + ">cast(" + name + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user