Book a Demo

Author Topic: Question about generics and interfaces  (Read 3161 times)

johnd

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Question about generics and interfaces
« on: March 10, 2007, 12:26:46 pm »
Hi All,

I want to model a base DAO interface using generics. In Java this would be:

public interface GenericDAO<T, ID extends Serializable> {

   T findById(ID id, boolean lock);

   List<T> findAll();

   List<T> findByExample(T exampleInstance);

   T makePersistent(T entity);

   void makeTransient(T entity);
}

I can not seem to work out how to this in EA for interfaces.

For classes I can use Class>>Detail>>Templates>>Type>>Parameterised options and this all works fine.

Any help would be appreciated.

John.






«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Question about generics and interfaces
« Reply #1 on: March 11, 2007, 04:53:44 am »
What happens if you set up a class with the generics as you describe, and then stereotype it as «interface»?
No, you can't have it!

johnd

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Question about generics and interfaces
« Reply #2 on: March 11, 2007, 08:34:57 am »
That's my work around for now. However the item appears with class icon in the project explorer and package view.

I am passsing the design to a third party for implementation and really want to avoid any confusion.

Do you know if there is another way of using generics with interfaces?

Thanks.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Question about generics and interfaces
« Reply #3 on: March 11, 2007, 11:40:15 am »
Sadly John, I do not.

EA support for generics - at least in the .Net world where I spend more of my time - is fairly new, and (IMHO) does not yet seem to be as fully featured as it should be.

Perhaps in time this will improve. Ideally, I'd like to see some progress before "the next major version" arrives, but I do not know what Sparx' plans are in this area.

This is something you should consider making as a suggestion. We (some of the user community) use this protocol:
  • Start a forum thread in the Suggestions and Requests section with the suggestion.
  • Issue a feature request to Sparx.
    • Use the Support link on the forum page, followed by Feature Request, OR from  the EA main menu choose Help | On-Line Resources | Request-a-Feature.
    • Paste the URL of the forum thread into the feature request.
  • Sparx now has the feature request, and can monitor the thread; they can post any workarounds they might have.
  • The user community can express their support, share ideas and refinements they might come up with, and engage in general discussion of the idea.

HTH, David
No, you can't have it!