You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/09/23 14:54:55 UTC

[1/3] git commit: Revert "WICKET-5350 remove wildcards from #ofList() and others"

Repository: wicket
Updated Branches:
  refs/heads/master ad0cdb01e -> fb8db6ce6


Revert "WICKET-5350 remove wildcards from #ofList() and others"

This reverts commit ee41e39a5695bef0f6fc3c31b38e5f78de21d018.

Revert to make Wildcard**Model classes deprecated.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/ffb5a972
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/ffb5a972
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/ffb5a972

Branch: refs/heads/master
Commit: ffb5a972015282e7b34b3f2f52c25c24ae619e03
Parents: ad0cdb0
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Sep 23 14:46:28 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Sep 23 14:46:28 2014 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/model/Model.java     | 18 +++---
 .../model/util/WildcardCollectionModel.java     | 57 ++++++++++++++++++
 .../wicket/model/util/WildcardListModel.java    | 62 ++++++++++++++++++++
 .../wicket/model/util/WildcardSetModel.java     | 57 ++++++++++++++++++
 4 files changed, 185 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/ffb5a972/wicket-core/src/main/java/org/apache/wicket/model/Model.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/Model.java b/wicket-core/src/main/java/org/apache/wicket/model/Model.java
index 4838d4b..8cdadac 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/Model.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/Model.java
@@ -24,10 +24,10 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.model.util.CollectionModel;
-import org.apache.wicket.model.util.ListModel;
 import org.apache.wicket.model.util.MapModel;
-import org.apache.wicket.model.util.SetModel;
+import org.apache.wicket.model.util.WildcardCollectionModel;
+import org.apache.wicket.model.util.WildcardListModel;
+import org.apache.wicket.model.util.WildcardSetModel;
 import org.apache.wicket.util.lang.Objects;
 
 
@@ -78,9 +78,9 @@ public class Model<T extends Serializable> implements IModel<T>
 	 *            The List, which may or may not be Serializable
 	 * @return A Model object wrapping the List
 	 */
-	public static <C> IModel<List<C>> ofList(final List<C> list)
+	public static <C> IModel<List<? extends C>> ofList(final List<? extends C> list)
 	{
-		return new ListModel<>(list);
+		return new WildcardListModel<>(list);
 	}
 
 	/**
@@ -110,9 +110,9 @@ public class Model<T extends Serializable> implements IModel<T>
 	 *            The Set, which may or may not be Serializable
 	 * @return A Model object wrapping the Set
 	 */
-	public static <C> IModel<Set<C>> ofSet(final Set<C> set)
+	public static <C> IModel<Set<? extends C>> ofSet(final Set<? extends C> set)
 	{
-		return new SetModel<>(set);
+		return new WildcardSetModel<>(set);
 	}
 
 	/**
@@ -125,9 +125,9 @@ public class Model<T extends Serializable> implements IModel<T>
 	 *            The Collection, which may or may not be Serializable
 	 * @return A Model object wrapping the Set
 	 */
-	public static <C> IModel<Collection<C>> ofCollection(final Collection<C> collection)
+	public static <C> IModel<Collection<? extends C>> of(final Collection<? extends C> collection)
 	{
-		return new CollectionModel<>(collection);
+		return new WildcardCollectionModel<>(collection);
 	}
 
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/ffb5a972/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
new file mode 100644
index 0000000..8a8d138
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.model.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+/**
+ * Based on <code>Model</code> but for any collections of serializable objects.
+ * 
+ * @author Timo Rantalaiho
+ * @param <T>
+ *            type of object inside collection
+ */
+public class WildcardCollectionModel<T> extends GenericBaseModel<Collection<? extends T>>
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Creates empty model
+	 */
+	public WildcardCollectionModel()
+	{
+	}
+
+	/**
+	 * Creates model that will contain <code>collection</code>
+	 * 
+	 * @param collection
+	 */
+	public WildcardCollectionModel(Collection<? extends T> collection)
+	{
+		setObject(collection);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected Collection<? extends T> createSerializableVersionOf(Collection<? extends T> object)
+	{
+		return new ArrayList<T>(object);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/ffb5a972/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
new file mode 100644
index 0000000..059e7c7
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.model.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Based on <code>Model</code> but for lists of serializable objects.
+ * 
+ * @author Timo Rantalaiho
+ * @param <T>
+ *            type of object inside list
+ */
+public class WildcardListModel<T> extends GenericBaseModel<List<? extends T>>
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Creates empty model
+	 */
+	public WildcardListModel()
+	{
+	}
+
+	/**
+	 * Creates model that will contain <code>list</code>
+	 * 
+	 * @param list
+	 * 
+	 */
+	public WildcardListModel(List<? extends T> list)
+	{
+		setObject(list);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected List<? extends T> createSerializableVersionOf(List<? extends T> object)
+	{
+		if (object == null)
+		{
+			return null;
+		}
+		return new ArrayList<T>(object);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/ffb5a972/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
new file mode 100644
index 0000000..97fabb7
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.model.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Based on <code>Model</code> but for sets of serializable objects.
+ * 
+ * @author Timo Rantalaiho
+ * @param <T>
+ *            type of object inside set
+ */
+public class WildcardSetModel<T> extends GenericBaseModel<Set<? extends T>>
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Creates empty model
+	 */
+	public WildcardSetModel()
+	{
+	}
+
+	/**
+	 * Creates model that will contain <code>set</code>
+	 * 
+	 * @param set
+	 */
+	public WildcardSetModel(Set<? extends T> set)
+	{
+		setObject(set);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected Set<? extends T> createSerializableVersionOf(Set<? extends T> object)
+	{
+		return new HashSet<T>(object);
+	}
+}
\ No newline at end of file


[3/3] git commit: WICKET-5350 Use Model.ofList()

Posted by mg...@apache.org.
WICKET-5350 Use Model.ofList()

Java 7 diamonds


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/fb8db6ce
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/fb8db6ce
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/fb8db6ce

Branch: refs/heads/master
Commit: fb8db6ce665858b3c9780cab0ff855d849a007dc
Parents: 562d1ee
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Sep 23 14:54:18 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Sep 23 14:54:18 2014 +0200

----------------------------------------------------------------------
 .../apache/wicket/examples/compref/CheckBoxSelectorPage.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/fb8db6ce/wicket-examples/src/main/java/org/apache/wicket/examples/compref/CheckBoxSelectorPage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/compref/CheckBoxSelectorPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/compref/CheckBoxSelectorPage.java
index 90d05bf..3163a5a 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/compref/CheckBoxSelectorPage.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/compref/CheckBoxSelectorPage.java
@@ -50,7 +50,7 @@ public class CheckBoxSelectorPage extends WicketExamplePage
 
 		final Form<?> form = new Form<>("form");
 		add(form);
-		final CheckGroup<Integer> checkgroup = new CheckGroup<Integer>("checkgroup", Arrays.asList(
+		final CheckGroup<Integer> checkgroup = new CheckGroup<>("checkgroup", Arrays.asList(
 			1, 2, 3, 4));
 		form.add(checkgroup);
 		checkgroup.add(new Check<>("check1", Model.of(1)));
@@ -84,8 +84,8 @@ public class CheckBoxSelectorPage extends WicketExamplePage
 								// backwards compatibility.
 			}
 		});
-		final CheckBoxMultipleChoice<Integer> choice = new CheckBoxMultipleChoice<Integer>(
-			"choice", Model.of(new ArrayList<Integer>()), Arrays.asList(1, 2, 3, 4));
+		final CheckBoxMultipleChoice<Integer> choice = new CheckBoxMultipleChoice<>(
+			"choice", Model.ofList(new ArrayList<Integer>()), Arrays.asList(1, 2, 3, 4));
 		form.add(choice);
 		form.add(new CheckboxMultipleChoiceSelector("choiceSelector", choice));
 		final CheckBox loose1 = new CheckBox("looseCheck1", Model.of(Boolean.FALSE));


[2/3] git commit: WICKET-5350 remove wildcards from #ofList() and others

Posted by mg...@apache.org.
WICKET-5350 remove wildcards from #ofList() and others

Reapply ee41e39a5695bef0f6fc3c31b38e5f78de21d018 by just making Wildcard**Model classes deprecated, instead of completely removing them.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/562d1ee5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/562d1ee5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/562d1ee5

Branch: refs/heads/master
Commit: 562d1ee536ebaa07206c90baebdda5280fbf68e3
Parents: ffb5a97
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Sep 23 14:49:58 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Sep 23 14:49:58 2014 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/wicket/model/Model.java  | 18 +++++++++---------
 .../model/util/WildcardCollectionModel.java       |  6 ++++--
 .../wicket/model/util/WildcardListModel.java      |  4 +++-
 .../wicket/model/util/WildcardSetModel.java       |  4 +++-
 4 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/562d1ee5/wicket-core/src/main/java/org/apache/wicket/model/Model.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/Model.java b/wicket-core/src/main/java/org/apache/wicket/model/Model.java
index 8cdadac..f48b26f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/Model.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/Model.java
@@ -24,10 +24,10 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.model.util.CollectionModel;
+import org.apache.wicket.model.util.ListModel;
 import org.apache.wicket.model.util.MapModel;
-import org.apache.wicket.model.util.WildcardCollectionModel;
-import org.apache.wicket.model.util.WildcardListModel;
-import org.apache.wicket.model.util.WildcardSetModel;
+import org.apache.wicket.model.util.SetModel;
 import org.apache.wicket.util.lang.Objects;
 
 
@@ -78,9 +78,9 @@ public class Model<T extends Serializable> implements IModel<T>
 	 *            The List, which may or may not be Serializable
 	 * @return A Model object wrapping the List
 	 */
-	public static <C> IModel<List<? extends C>> ofList(final List<? extends C> list)
+	public static <C> IModel<List<C>> ofList(final List<C> list)
 	{
-		return new WildcardListModel<>(list);
+		return new ListModel<>(list);
 	}
 
 	/**
@@ -110,9 +110,9 @@ public class Model<T extends Serializable> implements IModel<T>
 	 *            The Set, which may or may not be Serializable
 	 * @return A Model object wrapping the Set
 	 */
-	public static <C> IModel<Set<? extends C>> ofSet(final Set<? extends C> set)
+	public static <C> IModel<Set<C>> ofSet(final Set<C> set)
 	{
-		return new WildcardSetModel<>(set);
+		return new SetModel<>(set);
 	}
 
 	/**
@@ -125,9 +125,9 @@ public class Model<T extends Serializable> implements IModel<T>
 	 *            The Collection, which may or may not be Serializable
 	 * @return A Model object wrapping the Set
 	 */
-	public static <C> IModel<Collection<? extends C>> of(final Collection<? extends C> collection)
+	public static <C> IModel<Collection<C>> of(final Collection<C> collection)
 	{
-		return new WildcardCollectionModel<>(collection);
+		return new CollectionModel<>(collection);
 	}
 
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/562d1ee5/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
index 8a8d138..fe81b5f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardCollectionModel.java
@@ -26,7 +26,9 @@ import java.util.Collection;
  * @author Timo Rantalaiho
  * @param <T>
  *            type of object inside collection
+ * @deprecated Will be removed in Wicket 8
  */
+@Deprecated
 public class WildcardCollectionModel<T> extends GenericBaseModel<Collection<? extends T>>
 {
 	private static final long serialVersionUID = 1L;
@@ -52,6 +54,6 @@ public class WildcardCollectionModel<T> extends GenericBaseModel<Collection<? ex
 	@Override
 	protected Collection<? extends T> createSerializableVersionOf(Collection<? extends T> object)
 	{
-		return new ArrayList<T>(object);
+		return new ArrayList<>(object);
 	}
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/562d1ee5/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
index 059e7c7..5f241d5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardListModel.java
@@ -26,7 +26,9 @@ import java.util.List;
  * @author Timo Rantalaiho
  * @param <T>
  *            type of object inside list
+ * @deprecated Will be removed in Wicket 8
  */
+@Deprecated
 public class WildcardListModel<T> extends GenericBaseModel<List<? extends T>>
 {
 	private static final long serialVersionUID = 1L;
@@ -59,4 +61,4 @@ public class WildcardListModel<T> extends GenericBaseModel<List<? extends T>>
 		}
 		return new ArrayList<T>(object);
 	}
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/562d1ee5/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
index 97fabb7..bd3e11f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/util/WildcardSetModel.java
@@ -26,7 +26,9 @@ import java.util.Set;
  * @author Timo Rantalaiho
  * @param <T>
  *            type of object inside set
+ * @deprecated Will be removed in Wicket 8
  */
+@Deprecated
 public class WildcardSetModel<T> extends GenericBaseModel<Set<? extends T>>
 {
 	private static final long serialVersionUID = 1L;
@@ -54,4 +56,4 @@ public class WildcardSetModel<T> extends GenericBaseModel<Set<? extends T>>
 	{
 		return new HashSet<T>(object);
 	}
-}
\ No newline at end of file
+}