java.lang.Object
org.apache.wicket.model.Model<T>
- Type Parameters:
T
- The type of the Model Object
- All Implemented Interfaces:
Serializable
,IDetachable
,IModel<T>
,IObjectClassAwareModel<T>
,IClusterable
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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
detach()
Detaches model after use.boolean
Gets the model object.Returns the class of model objectint
hashCode()
static <T extends Serializable>
Model<T>of()
Factory methods for Model which uses type inference to make code shorter.static <C> IModel<Collection<C>>
of
(Collection<C> collection) Factory method for models that contain collections.static <T extends Serializable>
Model<T>of
(T object) Factory methods for Model which uses type inference to make code shorter.Factory method for models that contain lists.Factory method for models that contain maps.Factory method for models that contain sets.void
Set the model object; calls setObject(java.io.Serializable).toString()
-
Constructor Details
-
Model
public Model()Construct the model without providing an object. -
Model
Construct the model, setting the given object as the wrapped object.- Parameters:
object
- The model object proper
-
-
Method Details
-
ofList
Factory method for models that contain lists. This factory method will automatically rebuild a non-serializablelist
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
-
ofMap
Factory method for models that contain maps. This factory method will automatically rebuild a non-serializablemap
into a serializable one.- Type Parameters:
K
- key type in mapV
- value type in map- Parameters:
map
- The Map, which may or may not be Serializable- Returns:
- A Model object wrapping the Map
-
ofSet
Factory method for models that contain sets. This factory method will automatically rebuild a non-serializableset
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
Factory method for models that contain collections. This factory method will automatically rebuild a non-serializablecollection
into a serializableArrayList
.- Type Parameters:
C
- model type- Parameters:
collection
- The Collection, which may or may not be Serializable- Returns:
- A Model object wrapping the Set
-
of
Factory methods for Model which uses type inference to make code shorter. Equivalent tonew Model
.(object) - Type Parameters:
T
-- Parameters:
object
-- Returns:
- Model that contains
object
-
of
Factory methods for Model which uses type inference to make code shorter. Equivalent tonew Model
.() - Type Parameters:
T
-- Returns:
- Model that contains
object
-
getObject
Description copied from interface:IModel
Gets the model object.- Specified by:
getObject
in interfaceIModel<T extends Serializable>
- Returns:
- The model object
-
setObject
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 interfaceIModel<T extends Serializable>
- Parameters:
object
- the model object- See Also:
-
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 interfaceIDetachable
- Specified by:
detach
in interfaceIModel<T extends Serializable>
-
toString
-
hashCode
-
equals
-
getObjectClass
Description copied from interface:IObjectClassAwareModel
Returns the class of model object- Specified by:
getObjectClass
in interfaceIObjectClassAwareModel<T extends Serializable>
- Returns:
- class of model object or null if the class couldn't be determined
-