Daniel Pitts wrote:
You have to create a explicit Factory for the types you want to
create.
new Table<String, Number>(
new Factory<Number>() {
Number create(Number template) {
return template == null ? Integer.valueOf(0) :
Integer.valueOf(template.intValue());
}
}
).get("something");
Ok, I see but unfortunately thats not going to work, because it depends
on the client controlling the instantion of the Table its values. In
this case its Hibernate that controls this, by reflection and such.
Hibernate spits out a table of elements with values for which I have no
idea what kind of type they are, and I have to modify the returned value
if need be, without knowing the type.
(arrgh... If anybody wants a truck load of java consultants from
BigIntlConsultingCo, you can have them for free!!! Just grab them and
bag them and put them in your local zoo, out of harms way... Or send
them to a zoo in Siberia, if you prefer.)
I'll be more specific, the underlying system stores value messages in a
database controlled by hibernate. I am working on an architectural
framework that does not control the specifics of the diverse
implementations. the value messages are by default in our local
langauge. And somebody forgot to consider that these messages must be
available in other langauges as well. Since things are being used by
many projects already, a rewrite of the original code is out of the
question. So my solution is to add the locale functionality in the
outermost code, so we dont have to change the underlying code. But as
you might have gathered by now, since everything is in a generic type I
can not instantiate a correct return object and pass it through the
generic return type. This is where the problem lies.
Suggestions are wholeheartedly welcomed
tom