Created
June 22, 2015 13:58
-
-
Save dashorst/eb84199f86e109728dce to your computer and use it in GitHub Desktop.
Fix generics for ListView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/list/ListView.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/list/ListView.java | |
index 57f9d84..e179d9e 100644 | |
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/list/ListView.java | |
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/list/ListView.java | |
@@ -134,7 +134,7 @@ public abstract class ListView<T> extends AbstractRepeater | |
* @param model model containing a list of | |
* @see org.apache.wicket.Component#Component(String, IModel) | |
*/ | |
- public ListView(final String id, final IModel<? extends List<? extends T>> model) | |
+ public ListView(final String id, final IModel<? extends List<T>> model) | |
{ | |
super(id, model); | |
@@ -156,7 +156,7 @@ public abstract class ListView<T> extends AbstractRepeater | |
* List to cast to Serializable | |
* @see org.apache.wicket.Component#Component(String, IModel) | |
*/ | |
- public ListView(final String id, final List<? extends T> list) | |
+ public ListView(final String id, final List<T> list) | |
{ | |
this(id, Model.ofList(list)); | |
} | |
@@ -169,9 +169,9 @@ public abstract class ListView<T> extends AbstractRepeater | |
* @return The list of items in this list view. | |
*/ | |
@SuppressWarnings("unchecked") | |
- public final List<? extends T> getList() | |
+ public final List<T> getList() | |
{ | |
- final List<? extends T> list = (List<? extends T>)getDefaultModelObject(); | |
+ final List<T> list = (List<T>)getDefaultModelObject(); | |
if (list == null) | |
{ | |
return Collections.emptyList(); | |
@@ -364,7 +364,7 @@ public abstract class ListView<T> extends AbstractRepeater | |
* The list for the new model. The list must implement {@link Serializable}. | |
* @return This for chaining | |
*/ | |
- public ListView<T> setList(List<? extends T> list) | |
+ public ListView<T> setList(List<T> list) | |
{ | |
setDefaultModel(Model.ofList(list)); | |
return this; | |
@@ -638,9 +638,9 @@ public abstract class ListView<T> extends AbstractRepeater | |
* @return model object | |
*/ | |
@SuppressWarnings("unchecked") | |
- public final List<? extends T> getModelObject() | |
+ public final List<T> getModelObject() | |
{ | |
- return (List<? extends T>)getDefaultModelObject(); | |
+ return (List<T>)getDefaultModelObject(); | |
} | |
/** | |
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java | |
index 7690db2..b1f22a8 100644 | |
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java | |
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java | |
@@ -51,7 +51,7 @@ public abstract class PageableListView<T> extends ListView<T> implements IPageab | |
* @param itemsPerPage | |
* Number of rows to show on a page | |
*/ | |
- public PageableListView(final String id, final IModel<? extends List<? extends T>> model, | |
+ public PageableListView(final String id, final IModel<? extends List<T>> model, | |
int itemsPerPage) | |
{ | |
super(id, model); | |
@@ -70,7 +70,7 @@ public abstract class PageableListView<T> extends ListView<T> implements IPageab | |
* Number of rows to show on a page | |
* @see ListView#ListView(String, List) | |
*/ | |
- public PageableListView(final String id, final List<? extends T> list, final int itemsPerPage) | |
+ public PageableListView(final String id, final List<T> list, final int itemsPerPage) | |
{ | |
super(id, list); | |
this.itemsPerPage = itemsPerPage; | |
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PropertyListView.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PropertyListView.java | |
index b458ed0..ffd4286 100644 | |
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PropertyListView.java | |
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/list/PropertyListView.java | |
@@ -57,7 +57,7 @@ public abstract class PropertyListView<T> extends ListView<T> | |
* @param model | |
* wrapping a List | |
*/ | |
- public PropertyListView(final String id, final IModel<? extends List<? extends T>> model) | |
+ public PropertyListView(final String id, final IModel<? extends List<T>> model) | |
{ | |
super(id, model); | |
} | |
@@ -71,7 +71,7 @@ public abstract class PropertyListView<T> extends ListView<T> | |
* @param list | |
* unmodeled List | |
*/ | |
- public PropertyListView(final String id, final List<? extends T> list) | |
+ public PropertyListView(final String id, final List<T> list) | |
{ | |
super(id, list); | |
} | |
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/list/ListViewTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/list/ListViewTest.java | |
index 8ebf50f..f7bae68 100644 | |
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/list/ListViewTest.java | |
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/list/ListViewTest.java | |
@@ -64,19 +64,19 @@ public class ListViewTest extends WicketTestCase | |
@Test | |
public void generics() { | |
// a listView for numbers | |
- class NumberListView extends ListView<Number> { | |
+ class NumberListView <N extends Number> extends ListView<N> { | |
private static final long serialVersionUID = 1L; | |
// since the given list is not changed actually, we can safely | |
// accept lists accepting subtypes of numbers only | |
- public NumberListView(String id, IModel<? extends List<? extends Number>> model) | |
+ public NumberListView(String id, IModel<? extends List<N>> model) | |
{ | |
super(id, model); | |
} | |
@Override | |
- protected void populateItem(ListItem<Number> item) | |
+ protected void populateItem(ListItem<N> item) | |
{ | |
// non-fancy display of the number | |
add(new Label("label", item.getModel())); | |
@@ -86,7 +86,7 @@ public class ListViewTest extends WicketTestCase | |
IModel<List<Integer>> integers = new ListModel<>(new ArrayList<Integer>()); | |
// pass list of integers to the number listView | |
- new NumberListView("integers", integers); | |
+ new NumberListView<>("integers", integers); | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment