Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Generic question

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I want to do the following but I can't. I can only declare myGet() to return Object.

I can do this :



but it seems inelegant, as I have to repeat my declaration of the T parameter.
Is there a more elegant way?
 
Marshal
Posts: 26747
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about this?
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"cannot resolve symbol E".
 
Paul Clapham
Marshal
Posts: 26747
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(paying closer attention) Then what about this?If I understand your design, a TableRow<E> is a row that is encapsulated by an E object, not a row that contains E objects? In that case a SimpleTableModel<E> is going to encapsulate a list of TableRow<E> elements.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
unfortunately I need to access the class of TableRow too as I have a method :



 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I want to do the following but I can't. I can only declare myGet() to return Object.


Why are you saying that?
I don't understand as it compiles perfectly "as is".
Also did a simple test with TableRow<Integer> and works fine.
Here is the code:

Regards
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Essentially I want to do this :

[/qb]<hr></blockquote>

but I cannot, I have to do this :



Which is repetition and not elegant, but it seems like it is the only way.

D.
[ May 16, 2006: Message edited by: Don Kiddick ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really need to care about which kind of TableRow the TableModel is using?

If you just want an add method,



should work just fine, shouldn't it?
 
Paul Clapham
Marshal
Posts: 26747
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still don't understand why you need <E extends TableRow> anywhere. Are you going to be working with subclasses of TableRow -- or TableRow<X> -- in this class?
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Do you really need to care about which kind of TableRow the TableModel is using?



The only reason I do is that I have a subclass of SimpleTableModel, called EditableTableModel which parameterizes TableRow with EditableTableRow.


I still don't understand why you need <E extends TableRow> anywhere. Are you going to be working with subclasses of TableRow -- or TableRow<X> -- in this class?


Both.

Here's the whole code :

TableRow :


EditableTableRow :


SimpleTableModel :


SimpleEditableTableModel:



thanks for all your input,
D.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case, I don't think there is a way around

class SimpleTableModel<T, E extends TableRow<T>>
 
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic