[jboss-dev-forums] [Design the new POJO MicroContainer] - Adding handy isInstance(Object) method to TypeInfo
alesj
do-not-reply at jboss.com
Sat Nov 22 16:33:20 EST 2008
I'm thinking about adding convenient isInstance method to TypeInfo.
On ClassInfoImpl/JavassistTypeInfo it would use getType::isInstance,
but on PrimitiveInfo it would still look into progression.
The method would hide simple impl detail.
| TypeInfo ti = ...;
| Object value = ...; // not null
|
| //long version
| TypeInfoFactory tif = ti.getTypeInfoFactory();
| TypeInfo other = tif.getTypeInfo(value.getClass());
| boolean isInstance = ti.isAssignableFrom(other);
|
| // short
| boolean isInstance = ti.isInstance(value);
|
| // where this doesn't consider progression
| boolean isInstance = ti.getType().isInstance(value);
|
OK?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191505#4191505
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191505
More information about the jboss-dev-forums
mailing list