Is there any way get info if JavaScriptObject is one of defined overlay
objects?
Example:
I have native factory method which creates JavaScriptObjects:
class WeirdFactory
{
native JavaScriptObject create(String type)
{
if (type == "car") return { name: "e46", maker: "bmw", seats: "4"}
else if (type == "table") return { material: "wood", color: "brown"}
else if (type == "type i forgot to crate overlay object for")
return { id: "someId", name: "someName" }
return null;
}
}
class Car extends JavaScriptObject
{
native String name() /*-{ return this.name; }-*/;
native String maker() /*-{ return this.maker; }-*/;
native int seats() /*-{ return this.seats; }-*/;
}
class Table extends JavaScriptObject
{
native String material() /*-{ return this.material; }-*/;
native String color() /*-{ return this.color; }-*/;
}
Now I want to use this factory to create overlay objects:
<T> void getValue(Class<T> returnType, Callback<T> callback, String type)
{
JavaScriptObject value = weirdFactory.create(type);
// Here I need something like
// if (!JavaScriptObject.isDefined(value))
// {
// *handleUndefinedJSO(value);* // or throw new
IllegalArgumentException("Undefined overlay object")
// }
T returnValue = (T)value;
*
*
* *callback.returned(returnValue)
}
I need somehow check if *value* JavaScriptObject has defined custom overlay
object (... extends JavaScriptObject)
In pure Java I would catch ClassCastExcetion. But this does not work with
JavaScriptObject which simply casts to anything (from it's nature, it's
JavaScript object in the end after compilation).
Does anybody have idea how to get info if JavaScriptObject is one of
defined overlay objects?
regards
js
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/xp60qKjHptUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.