is it possible to instantiate an object from its class type on demand ?
with GWT.create(Foo.class),
it is possible to instantiate Foo object from Foo.class.
however GWT.create mandates the argument passed to create method to be
a class literal, known at compile time.
in cases where the argument is not a class literal, for example coming
from a map,
is there an alternative way to create object Foo from its Foo.class ?
for example, lets say we have a map populated like below:
// this map is populated
Map<ObjectA, Class<? extends Foo>> map;
Foo lookupFoo(ObjectA objectA) {
Class<? extends Foo> fooClazz = map.get(objectA);
return GWT.create(fooClazz);
}
this works in hosted mode, but doesnt compile.
is there any alternative way that this can be achieved without early
eagerly instantiation Foo objects ?
the good thing about GWT.create is that it creates the object on
demand. (i believe ?)
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home