Re: WO5.4: Generics for objectsWithFetchSpecification ???
Re: WO5.4: Generics for objectsWithFetchSpecification ???
- Subject: Re: WO5.4: Generics for objectsWithFetchSpecification ???
- From: Lachlan Deck <email@hidden>
- Date: Tue, 15 Jan 2008 02:50:49 +1100
On 15/01/2008, at 2:30 AM, Mike Schrag wrote:
Couldn't you handle both raw rows and EOs by using the type
NSArray<NSKeyValueCodingAdditions>?
You might as well return "Object" and not use generics if you do
this, though ... The point is that you WANT a more specific EO class.
I think Lachlan's basic concept is the clearest so far (if this
feature goes in at all):
@deprecated
public NSArray objectsWithFetchSpecification(EOFetchSpecification
fetchSpec) {...}
public NSArray<T> enterpriseObjectsWithFetchSpecification
(EOFetchSpecification<T> fetchSpec) {...}
this should be:
public <T extends EOEnterpriseObject> NSArray<T>
eosWithFetchSpecification(EOFetchSpecification<T> ..)
public NSArray<NSDictionary<String, ?>>
rawObjectsWithFetchSpecification(EOFetchSpecification fetchSpec)
{....}
... and this really isn't a ? type (which would imply that all the
values are the same type, you just don't know what it is) .. I
think it should just be:
public <T extends EOEnterpriseObject> NSArray<NSDictionary<String,
Object>> rawRowsWithFetchSpecification(EOFetchSpecification<T>
fetchSpec ...)
I put the T here because then you can always declare the proper
type of the fetch spec, but depending on whether you call eosWith
or rawRowsWith, it will give you back the right thing. One
question is whether these throw IllegalArgumentException if the
fetch spec claims to want raw rows and you use the wrong method, or
whether the method should override the setting in the fetch spec.
I'd suggest (re: override):
- rawObjectsWithFetchSpecification and
enterpriseObjectsWithFetchSpecification can safely override/ignore
the flag. They're new methods after all and won't break any existing
code.
- objectsWithFetchSpecification should behave as it always has.
Perhaps it and fetchSpecs flag don't even need to be deprecated to
maintain backwards compatibility. Don't know.
with regards,
--
Lachlan Deck
_______________________________________________
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