org.apache.wicket.model
Class Model<T extends Serializable>

java.lang.Object
  extended by org.apache.wicket.model.Model<T>
Type Parameters:
T - The type of the Model Object
All Implemented Interfaces:
Serializable, IClusterable, IDetachable, IModel<T>

public class Model<T extends Serializable>
extends Object
implements IModel<T>

Model is the basic implementation of an IModel. It just wraps a simple model object. The model object must be serializable, as it is stored in the session. If you have large objects to store, consider using LoadableDetachableModel instead of this class.

Author:
Chris Turner, Eelco Hillenius
See Also:
Serialized Form

Constructor Summary
Model()
          Construct the model without providing an object.
Model(T object)
          Construct the model, setting the given object as the wrapped object.
 
Method Summary
 void detach()
          Detaches model after use.
 boolean equals(Object obj)
           
 T getObject()
          Gets the model object.
 Object getObject(Component component)
          Deprecated. replace by IModel.getObject().
 int hashCode()
           
static
<T extends Serializable>
Model<T>
of()
          Factory methods for Model which uses type inference to make code shorter.
static
<C> IModel<Collection<? extends C>>
of(Collection<? extends C> set)
          Factory method for models that contain collections.
static
<C> IModel<List<? extends C>>
of(List<? extends C> list)
          Deprecated. see ofList(List)
static
<K,V> IModel<Map<K,V>>
of(Map<K,V> map)
          Deprecated. use ofMap(Map)
static
<C> IModel<Set<? extends C>>
of(Set<? extends C> set)
          Deprecated. replace by ofSet(java.util.Set).
static
<T extends Serializable>
Model<T>
of(T object)
          Factory methods for Model which uses type inference to make code shorter.
static
<C> IModel<List<? extends C>>
ofList(List<? extends C> list)
          Factory method for models that contain lists.
static
<K,V> IModel<Map<K,V>>
ofMap(Map<K,V> map)
          Factory method for models that contain maps.
static
<C> IModel<Set<? extends C>>
ofSet(Set<? extends C> set)
          Factory method for models that contain sets.
 void setObject(Component component, Object object)
          Deprecated. replace by IModel.setObject(Object).
 void setObject(T object)
          Set the model object; calls setObject(java.io.Serializable).
 String toString()
           
static
<C> IModel<List<? extends C>>
valueOf(List<? extends C> list)
          Deprecated. see of(List)
static
<K,V> IModel<Map<K,V>>
valueOf(Map<K,V> map)
          Deprecated. see of(Map)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Model

public Model()
Construct the model without providing an object.


Model

public Model(T object)
Construct the model, setting the given object as the wrapped object.

Parameters:
object - The model object proper
Method Detail

valueOf

@Deprecated
public static <K,V> IModel<Map<K,V>> valueOf(Map<K,V> map)
Deprecated. see of(Map)

Type Parameters:
K - type of key inside map
V - type of value inside map
Parameters:
map - The Map, which may or may not be Serializable
Returns:
A Model object wrapping the Map

valueOf

@Deprecated
public static <C> IModel<List<? extends C>> valueOf(List<? extends C> list)
Deprecated. see of(List)

Type Parameters:
C - type of object inside list
Parameters:
list - The List, which may or may not be Serializable
Returns:
A Model object wrapping the List

of

@Deprecated
public static <C> IModel<List<? extends C>> of(List<? extends C> list)
Deprecated. see ofList(List)

Factory method for models that contain lists. This factory method will automatically rebuild a nonserializable list into a serializable one.

Type Parameters:
C - model type
Parameters:
list - The List, which may or may not be Serializable
Returns:
A Model object wrapping the List

ofList

public static <C> IModel<List<? extends C>> ofList(List<? extends C> list)
Factory method for models that contain lists. This factory method will automatically rebuild a nonserializable list into a serializable one.

Type Parameters:
C - model type
Parameters:
list - The List, which may or may not be Serializable
Returns:
A Model object wrapping the List

of

@Deprecated
public static <K,V> IModel<Map<K,V>> of(Map<K,V> map)
Deprecated. use ofMap(Map)

Factory method for models that contain maps. This factory method will automatically rebuild a nonserializable map into a serializable one.

Type Parameters:
K - key type in map
V - value type in map
Parameters:
map - The Map, which may or may not be Serializable
Returns:
A Model object wrapping the Map

ofMap

public static <K,V> IModel<Map<K,V>> ofMap(Map<K,V> map)
Factory method for models that contain maps. This factory method will automatically rebuild a nonserializable map into a serializable one.

Type Parameters:
K - key type in map
V - value type in map
Parameters:
map - The Map, which may or may not be Serializable
Returns:
A Model object wrapping the Map

of

@Deprecated
public static <C> IModel<Set<? extends C>> of(Set<? extends C> set)
Deprecated. replace by ofSet(java.util.Set).

Factory method for models that contain sets. This factory method will automatically rebuild a nonserializable set into a serializable one.

Type Parameters:
C - model type
Parameters:
set - The Set, which may or may not be Serializable
Returns:
A Model object wrapping the Set

ofSet

public static <C> IModel<Set<? extends C>> ofSet(Set<? extends C> set)
Factory method for models that contain sets. This factory method will automatically rebuild a nonserializable set into a serializable one.

Type Parameters:
C - model type
Parameters:
set - The Set, which may or may not be Serializable
Returns:
A Model object wrapping the Set

of

public static <C> IModel<Collection<? extends C>> of(Collection<? extends C> set)
Factory method for models that contain collections. This factory method will automatically rebuild a nonserializable collection into a serializable ArrayList.

Type Parameters:
C - model type
Parameters:
set - The Collection, which may or may not be Serializable
Returns:
A Model object wrapping the Set

of

public static <T extends Serializable> Model<T> of(T object)
Factory methods for Model which uses type inference to make code shorter. Equivalent to new Model(object).

Type Parameters:
T -
Parameters:
object -
Returns:
Model that contains object

of

public static <T extends Serializable> Model<T> of()
Factory methods for Model which uses type inference to make code shorter. Equivalent to new Model().

Type Parameters:
T -
Parameters:
object -
Returns:
Model that contains object

getObject

public T getObject()
Description copied from interface: IModel
Gets the model object.

Specified by:
getObject in interface IModel<T extends Serializable>
Returns:
The model object
See Also:
IModel.getObject()

setObject

public void setObject(T object)
Set the model object; calls setObject(java.io.Serializable). The model object must be serializable, as it is stored in the session

Specified by:
setObject in interface IModel<T extends Serializable>
Parameters:
object - the model object
See Also:
IModel.setObject(Object)

detach

public void detach()
Description copied from interface: IDetachable
Detaches model after use. This is generally used to null out transient references that can be re-attached later.

Specified by:
detach in interface IDetachable
See Also:
IDetachable.detach()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

getObject

@Deprecated
public final Object getObject(Component component)
Deprecated. replace by IModel.getObject().

Parameters:
component -
Returns:
the model object

setObject

@Deprecated
public final void setObject(Component component,
                                       Object object)
Deprecated. replace by IModel.setObject(Object).

Parameters:
component -
object -

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.