User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)
Joachim Haagen Bøe wrote:
Now newObject should be a new object of what ever type parakTypes[k]
is. Which is a parameter passed on to a method. I'm invoking this
method later, but I need to know what kind of object newObject is to
be able to give it a value (through an on-screen editor that will be
added later).
I would go for a slightly different approach: package your editors as
classes, where each class implements
interface Editor
{
Class get EditableType();
void edit( Object editableTarget );
}
You would cast your generic Object onto the appropriate type inside the
edit() function in each of your editor classes. You would set up a
Map<Class,Editor> to pick the right editor to use for an arbitrary
object using:
map.get(editableTarget.getClass()).edit( editableTarget );
I know I can do an [instanceof ...]
but this requires that you hardcode all type names in the code ahead of
time...
Moises
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden