Author: thrantal
Date: Tue Jul 15 20:40:58 2008
New Revision: 677143
URL: http://svn.apache.org/viewvc?rev=677143&view=rev
Log:
WICKET-1745: Slowly getting rid of raw Model usage.
I'm not too happy with this solution, but am shipping it in anyway after
tossing it around for several hours. Feedbacks and fixes are most welcome!
(One) problem is that Model.of() is traditionally used both for
Model.of(List<T>) and Model.of(List<? extends T>) and you cannot just use a
wildcarded version in place of T. Overloading of() doesn't solve this either,
because the methods would have the same erasure.
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModelBase.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/ListModel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/MapModel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/SetModel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardCollectionModel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardListModel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardSetModel.java
Modified:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/compref/PalettePage.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListView.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/Model.java
Modified:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/compref/PalettePage.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/compref/PalettePage.java?rev=677143&r1=677142&r2=677143&view=diff
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/compref/PalettePage.java
(original)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/compref/PalettePage.java
Tue Jul 15 20:40:58 2008
@@ -25,7 +25,8 @@
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.model.Model;
+import org.apache.wicket.model.CollectionModel;
+import org.apache.wicket.model.ListModel;
/**
@@ -44,7 +45,7 @@
IChoiceRenderer<Person> renderer = new
ChoiceRenderer<Person>("fullName", "fullName");
final Palette<Person> palette = new Palette<Person>("palette",
- Model.valueOf(new ArrayList<Person>()),
Model.valueOf(persons), renderer, 10, true);
+ new ListModel<Person>(new ArrayList<Person>()), new
CollectionModel<Person>(persons), renderer, 10, true);
Form<?> form = new Form("form")
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java?rev=677143&r1=677142&r2=677143&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java
Tue Jul 15 20:40:58 2008
@@ -16,14 +16,13 @@
*/
package org.apache.wicket.markup.html.form;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
+import org.apache.wicket.model.WildcardListModel;
import org.apache.wicket.util.convert.IConverter;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.util.string.Strings;
@@ -63,7 +62,7 @@
*/
public AbstractChoice(final String id)
{
- this(id, new Model(new ArrayList<E>()), new
ChoiceRenderer<E>());
+ this(id, new WildcardListModel<E>(new ArrayList<E>()), new
ChoiceRenderer<E>());
}
/**
@@ -77,7 +76,7 @@
*/
public AbstractChoice(final String id, final List<? extends E> choices)
{
- this(id, new Model((Serializable)choices), new
ChoiceRenderer<E>());
+ this(id, new WildcardListModel<E>(choices), new
ChoiceRenderer<E>());
}
/**
@@ -94,7 +93,7 @@
public AbstractChoice(final String id, final List<? extends E> choices,
final IChoiceRenderer<E> renderer)
{
- this(id, new Model((Serializable)choices), renderer);
+ this(id, new WildcardListModel<E>(choices), renderer);
}
/**
@@ -110,7 +109,7 @@
*/
public AbstractChoice(final String id, IModel<T> model, final List<?
extends E> choices)
{
- this(id, model, new Model((Serializable)choices), new
ChoiceRenderer<E>());
+ this(id, model, new WildcardListModel<E>(choices), new
ChoiceRenderer<E>());
}
/**
@@ -129,7 +128,7 @@
public AbstractChoice(final String id, IModel<T> model, final List<?
extends E> choices,
final IChoiceRenderer<E> renderer)
{
- this(id, model, new Model((Serializable)choices), renderer);
+ this(id, model, new WildcardListModel<E>(choices), renderer);
}
/**
@@ -208,7 +207,7 @@
*/
public List<? extends E> getChoices()
{
- List<E> choices = (this.choices != null) ?
(List<E>)this.choices.getObject() : null;
+ List<? extends E> choices = (this.choices != null) ?
this.choices.getObject() : null;
if (choices == null)
{
throw new NullPointerException(
@@ -245,7 +244,7 @@
* the list of choices
* @return this for chaining
*/
- public final AbstractChoice<T, E> setChoices(List<T> choices)
+ public final AbstractChoice<T, E> setChoices(List<E> choices)
{
if ((this.choices != null))
{
@@ -254,7 +253,7 @@
addStateChange(new ChoicesListChange());
}
}
- this.choices = new Model((Serializable)choices);
+ this.choices = new WildcardListModel<E>(choices);
return this;
}
@@ -386,7 +385,7 @@
String displayValue = "";
if (objectClass != null && objectClass != String.class)
{
- final IConverter<T> converter =
this.getConverter(objectClass);
+ final IConverter<T> converter =
getConverter(objectClass);
displayValue = converter.convertToString(objectValue,
getLocale());
}
@@ -492,9 +491,5 @@
return "ChoiceListChange[component: " + getPath() + ",
old choices: " + oldChoices +
"]";
}
-
-
}
-
-
}
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListView.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListView.java?rev=677143&r1=677142&r2=677143&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListView.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListView.java
Tue Jul 15 20:40:58 2008
@@ -25,6 +25,7 @@
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.repeater.AbstractRepeater;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ListModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.collections.ReadOnlyIterator;
import org.apache.wicket.version.undo.Change;
@@ -78,7 +79,7 @@
* instance itself does not correspond to any markup, however, the generated
ListItems do.<br/>
*
* This means that methods like [EMAIL PROTECTED] #setRenderBodyOnly(boolean)}
and
- * [EMAIL PROTECTED] #add(org.apache.wicket.behavior.IBehavior)} should be
invoked on the [EMAIL PROTECTED] ListItem} that
+ * [EMAIL PROTECTED] #add(org.apache.wicket.behavior.IBehavior...)} should be
invoked on the [EMAIL PROTECTED] ListItem} that
* is given in [EMAIL PROTECTED] #populateItem(ListItem)} method.
* </p>
*
@@ -160,7 +161,7 @@
*/
public ListView(final String id, final List<T> list)
{
- this(id, Model.of(list));
+ this(id, new ListModel<T>(list));
}
/**
@@ -253,9 +254,9 @@
* @param item
* @return The link component
*/
- public final Link moveDownLink(final String id, final ListItem<T> item)
+ public final Link<Void> moveDownLink(final String id, final ListItem<T>
item)
{
- return new Link(id)
+ return new Link<Void>(id)
{
private static final long serialVersionUID = 1L;
@@ -265,7 +266,7 @@
@Override
public void onClick()
{
- final int index =
getList().indexOf(item.getDefaultModelObject());
+ final int index =
getList().indexOf(item.getModelObject());
if (index != -1)
{
addStateChange(new Change()
@@ -296,7 +297,7 @@
{
super.onBeforeRender();
setAutoEnable(false);
- if
(getList().indexOf(item.getDefaultModelObject()) == (getList().size() - 1))
+ if (getList().indexOf(item.getModelObject()) ==
(getList().size() - 1))
{
setEnabled(false);
}
@@ -312,9 +313,9 @@
* @param item
* @return The link component
*/
- public final Link moveUpLink(final String id, final ListItem<T> item)
+ public final Link<Void> moveUpLink(final String id, final ListItem<T>
item)
{
- return new Link(id)
+ return new Link<Void>(id)
{
private static final long serialVersionUID = 1L;
@@ -324,7 +325,7 @@
@Override
public void onClick()
{
- final int index =
getList().indexOf(item.getDefaultModelObject());
+ final int index =
getList().indexOf(item.getModelObject());
if (index != -1)
{
@@ -356,7 +357,7 @@
{
super.onBeforeRender();
setAutoEnable(false);
- if
(getList().indexOf(item.getDefaultModelObject()) == 0)
+ if (getList().indexOf(item.getModelObject()) ==
0)
{
setEnabled(false);
}
@@ -372,9 +373,9 @@
* @param item
* @return The link component
*/
- public final Link removeLink(final String id, final ListItem<T> item)
+ public final Link<Void> removeLink(final String id, final ListItem<T>
item)
{
- return new Link(id)
+ return new Link<Void>(id)
{
private static final long serialVersionUID = 1L;
@@ -388,7 +389,7 @@
{
private static final long
serialVersionUID = 1L;
- final int oldIndex =
getList().indexOf(item.getDefaultModelObject());
+ final int oldIndex =
getList().indexOf(item.getModelObject());
final T removedObject =
item.getModelObject();
@Override
@@ -402,7 +403,7 @@
item.modelChanging();
// Remove item and invalidate listView
- getList().remove(item.getDefaultModelObject());
+ getList().remove(item.getModelObject());
ListView.this.modelChanged();
ListView.this.removeAll();
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModel.java?rev=677143&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModel.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModel.java
Tue Jul 15 20:40:58 2008
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+/**
+ * Based on <code>Model</code> but for any collections of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class CollectionModel<T> extends CollectionModelBase<Collection<T>>
+{
+ public CollectionModel()
+ {
+ }
+
+ public CollectionModel(Collection<T> object)
+ {
+ setObject(object);
+ }
+
+
+ @Override
+ protected Collection<T> createSerializableVersionOf(Collection<T> object)
+ {
+ return new ArrayList<T>(object);
+ }
+}
\ No newline at end of file
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModelBase.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModelBase.java?rev=677143&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModelBase.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/CollectionModelBase.java
Tue Jul 15 20:40:58 2008
@@ -0,0 +1,102 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+import org.apache.wicket.util.lang.Objects;
+
+/**
+ * @author Timo Rantalaiho
+ */
+public abstract class CollectionModelBase<T> implements IModel<T>
+{
+ private static final long serialVersionUID = 1L;
+ private T object;
+
+ /**
+ * @see org.apache.wicket.model.IModel#getObject()
+ */
+ public T getObject()
+ {
+ return object;
+ }
+
+ /**
+ * Set the model object. The contents must be
+ * serializable, as they are stored in the session
+ *
+ * @param object the model object
+ * @see org.apache.wicket.model.IModel#setObject(Object)
+ */
+ public void setObject(T object)
+ {
+ if (!(object instanceof Serializable))
+ {
+ object = createSerializableVersionOf(object);
+ }
+ this.object = object;
+ }
+
+ protected abstract T createSerializableVersionOf(T object);
+
+ /**
+ * @see org.apache.wicket.model.IDetachable#detach()
+ */
+ public void detach()
+ {
+ if (object instanceof IDetachable)
+ {
+ ((IDetachable) object).detach();
+ }
+ }
+
+ /**
+ * @see Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("Model:classname=[");
+ sb.append(getClass().getName()).append("]");
+ sb.append(":object=[").append(object).append("]");
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hashCode(object);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+
+ }
+ if (!(obj instanceof CollectionModelBase))
+ {
+ return false;
+ }
+ CollectionModelBase<?> that = (CollectionModelBase<?>) obj;
+ return Objects.equal(object, that.object);
+ }
+}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/model/ListModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/ListModel.java?rev=677143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/model/ListModel.java
(added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/model/ListModel.java
Tue Jul 15 20:40:58 2008
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Based on <code>Model</code> but for lists of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class ListModel<T> extends CollectionModelBase<List<T>>
+{
+ public ListModel()
+ {
+ }
+
+ public ListModel(List<T> object)
+ {
+ setObject(object);
+ }
+
+
+ @Override
+ protected List<T> createSerializableVersionOf(List<T> object)
+ {
+ return new ArrayList<T>(object);
+ }
+}
\ No newline at end of file
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/model/MapModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/MapModel.java?rev=677143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/model/MapModel.java
(added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/model/MapModel.java Tue
Jul 15 20:40:58 2008
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Based on <code>Model</code> but for mapss of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class MapModel<K,V> extends CollectionModelBase<Map<K,V>>
+{
+ public MapModel()
+ {
+ }
+
+ public MapModel(Map<K,V> object)
+ {
+ setObject(object);
+ }
+
+ @Override
+ protected Map<K, V> createSerializableVersionOf(Map<K, V> object)
+ {
+ return new HashMap<K,V>(object);
+ }
+}
\ No newline at end of file
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/model/Model.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/Model.java?rev=677143&r1=677142&r2=677143&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/model/Model.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/model/Model.java Tue
Jul 15 20:40:58 2008
@@ -19,8 +19,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -40,7 +38,7 @@
* @author Eelco Hillenius
*
* @param <T>
- * The Model Object
+ * The type of the Model Object
*/
public class Model<T extends Serializable> implements IModel<T>
{
@@ -70,14 +68,14 @@
/**
* @param map
* The Map, which may or may not be Serializable
- * @deprecated see [EMAIL PROTECTED] Model#ofMap(Map)}
+ * @deprecated see [EMAIL PROTECTED] Model#of(Map)}
* @return A Model object wrapping the Map
*/
@SuppressWarnings("unchecked")
@Deprecated
- public static Model valueOf(final Map map)
+ public static <K, V> IModel<Map<K, V>> valueOf(final Map<K, V> map)
{
- return new Model(map instanceof Serializable ?
(Serializable)map : new HashMap(map));
+ return of(map);
}
/**
@@ -88,27 +86,25 @@
*/
@SuppressWarnings("unchecked")
@Deprecated
- public static Model valueOf(final List list)
+ public static <C> IModel<List<? extends C>> valueOf(final List<?
extends C> list)
{
- return new Model(list instanceof Serializable ?
(Serializable)list : new ArrayList(list));
+ return of(list);
}
/**
* Factory method for models that contain lists. This factory method
will automatically rebuild
* a nonserializable <code>list</code> into a serializable one.
*
- * @param <V>
- * value type in list
- * @param <T>
+ * @param <C>
* model type
* @param list
* The List, which may or may not be Serializable
* @return A Model object wrapping the List
*/
@SuppressWarnings("unchecked")
- public static <T> IModel<List<T>> of(final List<T> list)
+ public static <C> IModel<List<? extends C>> of(final List<? extends C>
list)
{
- return new Model((Serializable)(list instanceof Serializable ?
list : new ArrayList(list)));
+ return new WildcardListModel<C>(list);
}
/**
@@ -119,8 +115,6 @@
* key type in map
* @param <V>
* value type in map
- * @param <T>
- * model type
* @param map
* The Map, which may or may not be Serializable
* @return A Model object wrapping the Map
@@ -128,44 +122,38 @@
@SuppressWarnings("unchecked")
public static <K, V> IModel<Map<K, V>> of(final Map<K, V> map)
{
- return new Model((Serializable)(map instanceof Serializable ?
map : new HashMap<K, V>(map)));
+ return new MapModel<K,V>(map);
}
/**
* Factory method for models that contain sets. This factory method
will automatically rebuild a
* nonserializable <code>set</code> into a serializable one.
- *
- * @param <V>
- * value type in set
- * @param <T>
+ * @param <C>
* model type
* @param set
* The Set, which may or may not be Serializable
* @return A Model object wrapping the Set
*/
@SuppressWarnings("unchecked")
- public static <T> IModel<Set<T>> of(final Set<T> set)
+ public static <C> IModel<Set<? extends C>> of(final Set<? extends C>
set)
{
- return new Model((Serializable)(set instanceof Serializable ?
set : new HashSet<T>(set)));
+ return new WildcardSetModel<C>(set);
}
/**
* Factory method for models that contain collections. This factory
method will automatically
* rebuild a nonserializable <code>collection</code> into a
serializable [EMAIL PROTECTED] ArrayList}.
- *
- * @param <V>
- * value type in set
- * @param <T>
+ * @param <C>
* model type
* @param set
- * The Set, which may or may not be Serializable
+ * The Collection, which may or may not be Serializable
* @return A Model object wrapping the Set
*/
@SuppressWarnings("unchecked")
- public static <T> IModel<Collection<T>> of(final Collection<T> set)
+ public static <C> IModel<Collection<? extends C>> of(final Collection<?
extends C> set)
{
- return new Model((Serializable)(set instanceof Serializable ?
set : new ArrayList<T>(set)));
+ return new WildcardCollectionModel<C>(set);
}
@@ -268,7 +256,7 @@
{
if (this == obj)
return true;
- if (obj instanceof Model == false)
+ if (!(obj instanceof Model<?>))
{
return false;
}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/model/SetModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/SetModel.java?rev=677143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/model/SetModel.java
(added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/model/SetModel.java Tue
Jul 15 20:40:58 2008
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Based on <code>Model</code> but for sets of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class SetModel<T> extends CollectionModelBase<Set<T>>
+{
+ public SetModel()
+ {
+ }
+
+ public SetModel(Set<T> object)
+ {
+ setObject(object);
+ }
+
+
+ @Override
+ protected Set<T> createSerializableVersionOf(Set<T> object)
+ {
+ return new HashSet<T>(object);
+ }
+}
\ No newline at end of file
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardCollectionModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardCollectionModel.java?rev=677143&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardCollectionModel.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardCollectionModel.java
Tue Jul 15 20:40:58 2008
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+/**
+ * Based on <code>Model</code> but for any collections of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class WildcardCollectionModel<T> extends
CollectionModelBase<Collection<? extends T>>
+{
+ public WildcardCollectionModel()
+ {
+ }
+
+ public WildcardCollectionModel(Collection<? extends T> object)
+ {
+ setObject(object);
+ }
+
+
+ @Override
+ protected Collection<? extends T> createSerializableVersionOf(Collection<?
extends T> object)
+ {
+ return new ArrayList<T>(object);
+ }
+}
\ No newline at end of file
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardListModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardListModel.java?rev=677143&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardListModel.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardListModel.java
Tue Jul 15 20:40:58 2008
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Based on <code>Model</code> but for lists of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class WildcardListModel<T> extends CollectionModelBase<List<? extends
T>>
+{
+ public WildcardListModel()
+ {
+ }
+
+ public WildcardListModel(List<? extends T> object)
+ {
+ setObject(object);
+ }
+
+
+ @Override
+ protected List<? extends T> createSerializableVersionOf(List<? extends T>
object)
+ {
+ return new ArrayList<T>(object);
+ }
+}
\ No newline at end of file
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardSetModel.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardSetModel.java?rev=677143&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardSetModel.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/model/WildcardSetModel.java
Tue Jul 15 20:40:58 2008
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Based on <code>Model</code> but for sets of serializable objects.
+ *
+ * @author Timo Rantalaiho
+ */
+public class WildcardSetModel<T> extends CollectionModelBase<Set<? extends T>>
+{
+ public WildcardSetModel()
+ {
+ }
+
+ public WildcardSetModel(Set<? extends T> object)
+ {
+ setObject(object);
+ }
+
+
+ @Override
+ protected Set<? extends T> createSerializableVersionOf(Set<? extends T>
object)
+ {
+ return new HashSet<T>(object);
+ }
+}
\ No newline at end of file