Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Generics passed in parameter errors
    text
    copied!<p>I get a compilation error simillar to: The method <code>visitParents(Class&lt;C&gt;)</code> in some type is not applicable for the arguments <code>(Class&lt;MyClass&gt;)</code></p> <p>MyClass is something like: <code>public class SortableTable&lt;T&gt;{...}</code></p> <p>I prefer not to change the type parameter of SortableTable to <code>&lt;C&gt;</code> since many other classes will be effected negatively, also cannot change visitParents to take anything but <code>Class&lt;C&gt;</code> as a parameter. </p> <p>Any potential solutions will be appreciated.</p> <hr> <p>Thanks for your advice. I will try to be as specific as I can without filling the page with code.</p> <p>Error description on line "visitParents(SortableTable.class, visitor);":</p> <p>The method visitParents(Class"&lt;"C">", IVisitor"&lt;"C,R">") in the type Component is not applicable for the arguments (Class"&lt;"SortableTable">", IVisitor"&lt;"Component,Void">")</p> <pre><code>public class SelectAllFilterPanel extends Panel{private static final Logger log = Logger.getLogger(CorporateActionsPanel.class); private static final long serialVersionUID = 1L; public SelectAllFilterPanel(String id, final IModel&lt;Boolean&gt; model){ super(id); add(new AjaxCheckBox("selectAll", model){ private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { // TODO - do this properly final AjaxRequestTarget requestTarget = target; IVisitor&lt;Component, Void&gt; visitor = new IVisitor&lt;Component, Void&gt;(){ @Override public void component(Component component, IVisit visit) { SortableTable&lt;?&gt; table = (SortableTable&lt;?&gt;)component; table.visitChildren(CheckBox.class, new IVisitor&lt;Component, Void&gt;(){ @Override public void component(Component component, IVisit visit) { if (!component.getId().equals("selectAll")){ CheckBox checkbox = (CheckBox)component; if (model.getObject()) checkbox.setModelObject(true); else checkbox.setModelObject(false); requestTarget.add(checkbox); } } }); visit.stop(); } }; visitParents(SortableTable.class, visitor); target.add(this); } }); }} </code></pre> <p>SortableTable Class:</p> <pre><code>public class SortableTable&lt;T&gt; extends DataTable&lt;T, String&gt; { private HeadersToolbar headerToolbar; @SuppressWarnings("unchecked") public SortableTable(String tableId, SortableTableDataProvider&lt;T&gt; dataProvider, int maxRows) { this(tableId, dataProvider.getColumns(), dataProvider, maxRows); } @SuppressWarnings("unchecked") public SortableTable(String tableId, List&lt;IColumnConfig&lt;T, String&gt;&gt; columns, ISortableDataProvider&lt;T, String&gt; dataProvider, int maxRows) { super(tableId, new java.util.LinkedList&lt;IColumn&lt;T, String&gt;&gt;(columns), dataProvider, maxRows); addTopToolbar(new NavigationToolbar(this)); addTopToolbar(headerToolbar = new HeadersToolbar(this, dataProvider)); addBottomToolbar(new NoRecordsToolbar(this)); setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance()); } public void setHeaderVisible(boolean visible) { headerToolbar.setVisibilityAllowed(visible); } public boolean isHeaderVisible() { return headerToolbar.isVisibilityAllowed(); } @Override protected Item&lt;T&gt; newRowItem(String id, int index, IModel&lt;T&gt; model) { return new OddEvenItem&lt;T&gt;(id, index, model); }} </code></pre> <p>visitParent signature is:</p> <pre><code> public final &lt;R, C extends MarkupContainer&gt; R visitParents(final Class&lt;C&gt; parentClass, final IVisitor&lt;C, R&gt; visitor) { return visitParents(parentClass, visitor, new AllVisitFilter()); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload