Re: WO5.4: Generics for objectsWithFetchSpecification ???
Re: WO5.4: Generics for objectsWithFetchSpecification ???
- Subject: Re: WO5.4: Generics for objectsWithFetchSpecification ???
- From: Anjo Krank <email@hidden>
- Date: Mon, 7 Jan 2008 16:13:01 +0100
Am 07.01.2008 um 15:53 schrieb Mike Schrag:
You cannot right now ... Either EOFetchSpec would have to be
genericized with the objects that it will return as well has having
ec.objectsWithFetchSpec genericized probably with a single method
generic to do it. As far as valueForKey, I don't think there's any
way to make that generic in any meaningful way -- you're essentially
performing reflection, so I suspect you will never see a generic
version of that.
Well... I didn't think this through but you could have:
public class Key<T> {
public String key;
...
}
public class MyEO {
Key SOME_KEY = new Key<NSTimestamp>("someKey");
...
public T valueForKey(Key<T> key) {
return valueForKey(key.key);
}
...
}
...
NSTimestamp ts = myEO.valueForKey(MyEO.SOME_KEY);
...
This would also allow for key.append(otherKey) and similar things.
As for the FetchSpec, you could have
NSArray<MyEO> = ec.objectsWithFetchSpecification(spec, MyEO.class)
and
public class MyEC extends ERXEC {
<T extends EOEnterpriseObject> NSArray<T>
objectsWithFetchSpecification(EOFetchSpec spec, Class<T> clazz) {
return objectsWithFetchSpecification(spec);
}
}
(or your generic FetchSpec, of course)
Now it may be that this doesn't compile, but the general idea should
be clear.
Cheers, Anjo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden