FAQ
Generic types
-------------

Key: CAY-942
URL: https://issues.apache.org/cayenne/browse/CAY-942
Project: Cayenne
Issue Type: Improvement
Reporter: Scott Anderson
Assignee: Andrus Adamchik
Priority: Minor


I realize that this would restrict functionality to Java 5+, but I still believe it would be a good option to have for the code generator in the modeler:

Add, as an option, generic types to Lists in generated classes. It's quite annoying to have to cast types; much of my code looks like this:
for(Object o : someObject.getSomeManyToManyField()) {
TheTypeIWanted ttiw = (TheTypeIWanted) o;
...
}

With generics, it would be:
for(TheTypeIWanted ttiw : someObject.getSomeManyToManyField()) {
...
}

It'd also be nice if the core libraries had generics. For example, "Object DataObjectUtils.objectForPk(Class, int)" could be changed to "T DataObjectUtils.objectForPk(Class<T>, int)" to avoid casting.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Search Discussions

  • Anonymous at Dec 14, 2007 at 11:34 pm
    [ https://issues.apache.org/cayenne/browse/CAY-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12633 ]

    Scott Anderson commented on CAY-942:
    ------------------------------------

    This would also have the advantage of restricting the class passed to objectForPk to a Class<? extends CayenneDataObject>

    public static <T extends CayenneDataObject> T objectForPk(Class<T> type, int pk);
    Generic types
    -------------

    Key: CAY-942
    URL: https://issues.apache.org/cayenne/browse/CAY-942
    Project: Cayenne
    Issue Type: Improvement
    Reporter: Scott Anderson
    Assignee: Andrus Adamchik
    Priority: Minor

    I realize that this would restrict functionality to Java 5+, but I still believe it would be a good option to have for the code generator in the modeler:
    Add, as an option, generic types to Lists in generated classes. It's quite annoying to have to cast types; much of my code looks like this:
    for(Object o : someObject.getSomeManyToManyField()) {
    TheTypeIWanted ttiw = (TheTypeIWanted) o;
    ...
    }
    With generics, it would be:
    for(TheTypeIWanted ttiw : someObject.getSomeManyToManyField()) {
    ...
    }
    It'd also be nice if the core libraries had generics. For example, "Object DataObjectUtils.objectForPk(Class, int)" could be changed to "T DataObjectUtils.objectForPk(Class<T>, int)" to avoid casting.
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Dec 14, 2007 at 11:48 pm
    [ https://issues.apache.org/cayenne/browse/CAY-942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

    Ari Maniatis closed CAY-942.
    ----------------------------

    Resolution: Fixed
    Fix Version/s: 3.0
    Assignee: Ari Maniatis (was: Andrus Adamchik)

    Generics have already been implemented in trunk and many will be available in 3.0M3. This is ongoing work and more needs to be done over time, but a large part of this is complete.
    Generic types
    -------------

    Key: CAY-942
    URL: https://issues.apache.org/cayenne/browse/CAY-942
    Project: Cayenne
    Issue Type: Improvement
    Reporter: Scott Anderson
    Assignee: Ari Maniatis
    Priority: Minor
    Fix For: 3.0


    I realize that this would restrict functionality to Java 5+, but I still believe it would be a good option to have for the code generator in the modeler:
    Add, as an option, generic types to Lists in generated classes. It's quite annoying to have to cast types; much of my code looks like this:
    for(Object o : someObject.getSomeManyToManyField()) {
    TheTypeIWanted ttiw = (TheTypeIWanted) o;
    ...
    }
    With generics, it would be:
    for(TheTypeIWanted ttiw : someObject.getSomeManyToManyField()) {
    ...
    }
    It'd also be nice if the core libraries had generics. For example, "Object DataObjectUtils.objectForPk(Class, int)" could be changed to "T DataObjectUtils.objectForPk(Class<T>, int)" to avoid casting.
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Feb 19, 2008 at 8:39 pm
    [ https://issues.apache.org/cayenne/browse/CAY-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12740#action_12740 ]

    Scott Anderson commented on CAY-942:
    ------------------------------------

    Awesome; I've built the library from SVN, and have fell in love with it - great work!

    Are there any plans to add generics to the Query objects?
    Generic types
    -------------

    Key: CAY-942
    URL: https://issues.apache.org/cayenne/browse/CAY-942
    Project: Cayenne
    Issue Type: Improvement
    Reporter: Scott Anderson
    Assignee: Ari Maniatis
    Priority: Minor
    Fix For: 3.0


    I realize that this would restrict functionality to Java 5+, but I still believe it would be a good option to have for the code generator in the modeler:
    Add, as an option, generic types to Lists in generated classes. It's quite annoying to have to cast types; much of my code looks like this:
    for(Object o : someObject.getSomeManyToManyField()) {
    TheTypeIWanted ttiw = (TheTypeIWanted) o;
    ...
    }
    With generics, it would be:
    for(TheTypeIWanted ttiw : someObject.getSomeManyToManyField()) {
    ...
    }
    It'd also be nice if the core libraries had generics. For example, "Object DataObjectUtils.objectForPk(Class, int)" could be changed to "T DataObjectUtils.objectForPk(Class<T>, int)" to avoid casting.
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Feb 19, 2008 at 10:42 pm
    [ https://issues.apache.org/cayenne/browse/CAY-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12741#action_12741 ]

    Ari Maniatis commented on CAY-942:
    ----------------------------------

    Yes, it will be done, but the best way forward isn't 100% clear yet. See this for discussion:

    http://markmail.org/message/sewk6jevobnkc6jz
    Generic types
    -------------

    Key: CAY-942
    URL: https://issues.apache.org/cayenne/browse/CAY-942
    Project: Cayenne
    Issue Type: Improvement
    Reporter: Scott Anderson
    Assignee: Ari Maniatis
    Priority: Minor
    Fix For: 3.0


    I realize that this would restrict functionality to Java 5+, but I still believe it would be a good option to have for the code generator in the modeler:
    Add, as an option, generic types to Lists in generated classes. It's quite annoying to have to cast types; much of my code looks like this:
    for(Object o : someObject.getSomeManyToManyField()) {
    TheTypeIWanted ttiw = (TheTypeIWanted) o;
    ...
    }
    With generics, it would be:
    for(TheTypeIWanted ttiw : someObject.getSomeManyToManyField()) {
    ...
    }
    It'd also be nice if the core libraries had generics. For example, "Object DataObjectUtils.objectForPk(Class, int)" could be changed to "T DataObjectUtils.objectForPk(Class<T>, int)" to avoid casting.
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedDec 14, '07 at 11:30p
activeFeb 19, '08 at 10:42p
posts5
users1
websitecayenne.apache.org

1 user in discussion

Anonymous: 5 posts

People

Translate

site design / logo © 2021 Grokbase