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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to