You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Aristedes Maniatis <ar...@maniatis.org> on 2007/11/17 00:56:38 UTC

Re: svn commit: r595869 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: ./ access/trans/ query/ remote/

On 17/11/2007, at 10:24 AM, aadamchik@apache.org wrote:

>      * Returns a collection of objects that are registered with this  
> ObjectContext and
>      * have a state PersistenceState.NEW
>      */
> -    Collection newObjects();
> +    Collection<?> newObjects();

Is that right? As I understand it, <?> should be used when you have  
one type of object and you don't know which which type it is, but  
<Object> should be used when you have a mixture of different types of  
object.

I don't have a reference for that right now, but that was my  
recollection.

Ari



-------------------------->
Aristedes Maniatis
phone +61 2 9660 9700
PGP fingerprint 08 57 20 4B 80 69 59 E2  A9 BF 2D 48 C2 20 0C C8



Re: svn commit: r595869 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: ./ access/trans/ query/ remote/

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 17/11/2007, at 11:34 AM, Aristedes Maniatis wrote:

>
> On 17/11/2007, at 11:19 AM, Andrus Adamchik wrote:
>
>> I have no idea. I am just overwhelmed with millions of Eclipse  
>> warnings :-)
>
>> Anyone else has a reference?
>>
>> Andrus
>
>
> I found these articles the best for tips and tricks when I was first  
> working on generics:
>
> http://www.onjava.com/pub/a/onjava/excerpt/javaian5_chap04/index.html
> http://www.ibm.com/developerworks/java/library/j-jtp01255.html
>
>
> Ari


I came across that article about the subtleties of using <?> and  
<Object>:

http://www.onjava.com/pub/a/onjava/excerpt/javaian5_chap04/index.html

down under the heading "Type Parameter Wildcards" especially. There is  
no clear rule about when to use each, but the notes there are quite  
helpful I think.


Ari





-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: svn commit: ec - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: ./ access/trans/ query/ remote/

Posted by Robert Zeigler <ro...@puregumption.com>.
<?> is appropriate.
Unless you want to parameterize the method. But otherwise, yes, <?> is  
the right choice.
List<Object> says it's a list of objects. It can only be assigned to a  
to list of objects.
List<?> says it's a list of something, but you don't know what.
Those are two slightly different statements.
For example:

List<Object> foo1 = new ArrayList<Object>(); //legal
List<?> foo2 = new ArrayList<Object>(); //also legal.
List<Object> foo3 = new ArrayList<Persistent>(); //illegal; you'll get  
a compile-time error.
List<?> foo4 = new ArrayList<Persistent>();//this is legal.

other comments...
foo1.add(somePersistentObject); will be legal.
foo4.add(somePersistentObject) will NOT be legal, because foo4 is of  
wildctionard.

The other option, as i mentioned, is to parameterize your method...

public <T> List<T> getSomeCollection() { }

Or even
public <T extends Persistent> List<T> getSomeCollection();

Robert

On Nov 18, 2007, at 11/189:08 AM , Andrus Adamchik wrote:

> Didn't find an answer for this particular case in the articles below  
> (although they were informative otherwise)... Looking at the JDK's  
> own classes, I see a few of "Collection<?> getSomething()" methods  
> in various places.
>
> Andrus
>
>
> On Nov 16, 2007, at 7:34 PM, Aristedes Maniatis wrote:
>
>>
>> On 17/11/2007, at 11:19 AM, Andrus Adamchik wrote:
>>
>>> I have no idea. I am just overwhelmed with millions of Eclipse  
>>> warnings :-)
>>
>>> Anyone else has a reference?
>>>
>>> Andrus
>>
>>
>> I found these articles the best for tips and tricks when I was  
>> first working on generics:
>>
>> http://www.onjava.com/pub/a/onjava/excerpt/javaian5_chap04/index.html
>> http://www.ibm.com/developerworks/java/library/j-jtp01255.html
>>
>>
>> Ari
>>
>>
>> -------------------------->
>> ish
>> http://www.ish.com.au
>> Level 1, 30 Wilson Street Newtown 2042 Australia
>> phone +61 2 9550 5001   fax +61 2 9550 4001
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>
>>
>>
>


Re: svn commit: r595869 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: ./ access/trans/ query/ remote/

Posted by Andrus Adamchik <an...@objectstyle.org>.
Didn't find an answer for this particular case in the articles below  
(although they were informative otherwise)... Looking at the JDK's  
own classes, I see a few of "Collection<?> getSomething()" methods in  
various places.

Andrus


On Nov 16, 2007, at 7:34 PM, Aristedes Maniatis wrote:

>
> On 17/11/2007, at 11:19 AM, Andrus Adamchik wrote:
>
>> I have no idea. I am just overwhelmed with millions of Eclipse  
>> warnings :-)
>
>> Anyone else has a reference?
>>
>> Andrus
>
>
> I found these articles the best for tips and tricks when I was  
> first working on generics:
>
> http://www.onjava.com/pub/a/onjava/excerpt/javaian5_chap04/index.html
> http://www.ibm.com/developerworks/java/library/j-jtp01255.html
>
>
> Ari
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>
>


Re: svn commit: r595869 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: ./ access/trans/ query/ remote/

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 17/11/2007, at 11:19 AM, Andrus Adamchik wrote:

> I have no idea. I am just overwhelmed with millions of Eclipse  
> warnings :-)

> Anyone else has a reference?
>
> Andrus


I found these articles the best for tips and tricks when I was first  
working on generics:

http://www.onjava.com/pub/a/onjava/excerpt/javaian5_chap04/index.html
http://www.ibm.com/developerworks/java/library/j-jtp01255.html


Ari


-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: svn commit: r595869 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: ./ access/trans/ query/ remote/

Posted by Andrus Adamchik <an...@objectstyle.org>.
I have no idea. I am just overwhelmed with millions of Eclipse  
warnings :-)

Anyone else has a reference?

Andrus

On Nov 16, 2007, at 6:56 PM, Aristedes Maniatis wrote:
>
> On 17/11/2007, at 10:24 AM, aadamchik@apache.org wrote:
>
>>      * Returns a collection of objects that are registered with  
>> this ObjectContext and
>>      * have a state PersistenceState.NEW
>>      */
>> -    Collection newObjects();
>> +    Collection<?> newObjects();
>
> Is that right? As I understand it, <?> should be used when you have  
> one type of object and you don't know which which type it is, but  
> <Object> should be used when you have a mixture of different types  
> of object.
>
> I don't have a reference for that right now, but that was my  
> recollection.
>
> Ari
>
>
>
> -------------------------->
> Aristedes Maniatis
> phone +61 2 9660 9700
> PGP fingerprint 08 57 20 4B 80 69 59 E2  A9 BF 2D 48 C2 20 0C C8
>
>
>