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 <[email protected]>
Authored: Tue Sep 23 14:46:28 2014 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
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

Reply via email to