T
- The type of the Model Objectpublic class Model<T extends Serializable> extends Object implements IObjectClassAwareModel<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.Constructor and Description |
---|
Model()
Construct the model without providing an object.
|
Model(T object)
Construct the model, setting the given object as the wrapped object.
|
Modifier and Type | Method and Description |
---|---|
void |
detach()
Detaches model after use.
|
boolean |
equals(Object obj) |
T |
getObject()
Gets the model object.
|
Class<T> |
getObjectClass()
Returns the class of model object
|
int |
hashCode() |
static <T extends Serializable> |
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> |
of(T object)
Factory methods for Model which uses type inference to make code shorter.
|
static <C> IModel<List<C>> |
ofList(List<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<C>> |
ofSet(Set<C> set)
Factory method for models that contain sets.
|
void |
setObject(T object)
Set the model object; calls setObject(java.io.Serializable).
|
String |
toString() |
public Model()
public Model(T object)
object
- The model object properpublic static <C> IModel<List<C>> ofList(List<C> list)
list
into a serializable one.C
- model typelist
- The List, which may or may not be Serializablepublic static <K,V> IModel<Map<K,V>> ofMap(Map<K,V> map)
map
into a serializable one.K
- key type in mapV
- value type in mapmap
- The Map, which may or may not be Serializablepublic static <C> IModel<Set<C>> ofSet(Set<C> set)
set
into a serializable one.C
- model typeset
- The Set, which may or may not be Serializablepublic static <C> IModel<Collection<C>> of(Collection<C> collection)
collection
into a serializable ArrayList
.C
- model typecollection
- The Collection, which may or may not be Serializablepublic static <T extends Serializable> Model<T> of(T object)
new Model(object)
.of
in interface IModel<T extends Serializable>
T
- object
- object
public static <T extends Serializable> Model<T> of()
new Model()
.T
- object
public T getObject()
IModel
getObject
in interface IModel<T extends Serializable>
public void setObject(T object)
setObject
in interface IModel<T extends Serializable>
object
- the model objectIModel.setObject(Object)
public void detach()
IDetachable
detach
in interface IDetachable
detach
in interface IModel<T extends Serializable>
public Class<T> getObjectClass()
IObjectClassAwareModel
getObjectClass
in interface IObjectClassAwareModel<T extends Serializable>
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.