> Here is what I'm trying to do in code...
>
[quoted text clipped - 17 lines]
> anything in my searches for how to make something like this work. Any
> help is appreciated.
> > Here is what I'm trying to do in code...
>
[quoted text clipped - 19 lines]
>
> robert- Hide quoted text -- Show quoted text -
I checked out the link you're pointing to, but I'm still not achieving
the results I am looking for. I did a little more research, and I'm
thinking isInstance is more what I'm looking for. So, I modified my
code to look like this...
public DataModel getParentType(DataModel child, Class classType) {
DataModel retVal = null;
System.out.println(child.getClass());
System.out.println(classType);
if (child != null &&
child.getClass().isInstance(classType.getClass())) {
retVal = child;
} else {
this.getParentType((DataModel) child.getParent(), classType);
}
return retVal;
}
However, this never equates to true, even though, when I look at the
System.outs, there is a point where the printed information is the
same. Any more suggestions?
Tom Hawtin - 24 Jan 2007 19:37 GMT
> child.getClass().isInstance(classType.getClass())) {
classType.getClass() will be Class, and the argument of isInstance is
rarely a Class.
classType.isInstance(child)
Tom Hawtin
Jason Cavett - 24 Jan 2007 21:10 GMT
> > child.getClass().isInstance(classType.getClass())) {classType.getClass() will be Class, and the argument of isInstance is
> rarely a Class.
>
> classType.isInstance(child)
>
> Tom Hawtin
Whoops. My mistake. I forgot to change that in my post (it's changed
in my code). Anyway, here's the issue...the classes match (I tested
using the Eclipse debugger). Problem is, my condition is never met. I
am at a loss. Anything else I should nkow about isInstance(Object)
that isn't in the Javadocs?
Jason Cavett - 24 Jan 2007 21:20 GMT
> > > child.getClass().isInstance(classType.getClass())) {classType.getClass() will be Class, and the argument of isInstance is
> > rarely a Class.
[quoted text clipped - 6 lines]
> am at a loss. Anything else I should nkow about isInstance(Object)
> that isn't in the Javadocs?
Haha, wow...nevermind. Stupid error.
I was returning null in the end...forgot to set retVal on the second
case.