• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WO5.4: Generics for objectsWithFetchSpecification ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: WO5.4: Generics for objectsWithFetchSpecification ???
      • From: Mike Schrag <email@hidden>
References: 
 >WO5.4: Generics for objectsWithFetchSpecification ??? (From: Gaastra Dennis - WO Lists <email@hidden>)
 >Re: WO5.4: Generics for objectsWithFetchSpecification ??? (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: What's a good way to handle orders?
  • Next by Date: Re: WO5.4: Generics for objectsWithFetchSpecification ???
  • Previous by thread: Re: WO5.4: Generics for objectsWithFetchSpecification ???
  • Next by thread: Re: WO5.4: Generics for objectsWithFetchSpecification ???
  • Index(es):
    • Date
    • Thread