Skip to main content

Generics are killing me again ...

1 reply [Last post]
kleopatra
Offline
Joined: 2003-06-11
Points: 0

asked over at OTN:

https://forums.oracle.com/forums/thread.jspa?threadID=2270021&tstart=0

for your convenience, trying to copy to here (might get garbled, this editor ... s* ;-)

My personal enemies hit again: trying something really simple, trigger is an enhancement request in Swingx:

http://java.net/jira/browse/SWINGX-968

boils down to allow some kind of grouping (and possibly resorting) of menu items in the ColumnControlButton, should be easily pluggable, no code breaking changes allowed. My go for it is a one-method interface which ... well ... splits a list of Actions into sublists, then the controlButton simply places a separator between the per-list actions.

[prettifyclass="jive-code jive-java"] <font color="darkgreen">// existing api on ColumnControlPopup</font> <font color="darkgreen">/**  *  Creates and adds menuItems from the given actions  */</font> <font color="navy"><b>void</b></font> addAdditionalActions(List<? <font color="navy"><b>extends</b></font> Action> actions);   <font color="navy"><b>interface</b></font> Grouper <font color="navy">{</font>          <font color="darkgreen">/**      *   splits the given List of Actions into groups      */</font>      List<List<????>> group(List<? <font color="navy"><b>extends</b></font> Action> actions) <font color="navy">}</font>   [/prettify]

what is the correct code for the "????" - it must be of type Actions somehow, but cant make it, experimental permutations of wildcards, Ts, ... they all went wrong at one point or other, except one - which looks ... ehem ... clumsy ...:

[prettifyclass="jive-code jive-java"]   List<List<Action>> group(List<? <font color="navy"><b>extends</b></font> Action> actions); [/prettify]

Some kind soul please pull me out of that misery

Thanks

Jeanette

 

 

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kleopatra
Offline
Joined: 2003-06-11
Points: 0

fyi, got a workable suggestion over at OTN (better view it there, cant make the formatting work here)

interface ActionGrouper {

    <A extends Action> List<List<A>> group(List<A> actions);

}

 

Thanks

Jeanette