Module is.codion.framework.model
Package is.codion.framework.model
Class DefaultEntityModel<M extends DefaultEntityModel<M,E,T>,E extends AbstractEntityEditModel,T extends EntityTableModel<E>>
java.lang.Object
is.codion.framework.model.DefaultEntityModel<M,E,T>
- Type Parameters:
M
- the type ofDefaultEntityModel
used for detail modelsE
- the type ofAbstractEntityEditModel
used by thisEntityModel
T
- the type ofEntityTableModel
used by thisEntityModel
- All Implemented Interfaces:
EntityModel<M,
E, T>
- Direct Known Subclasses:
SwingEntityModel
public class DefaultEntityModel<M extends DefaultEntityModel<M,E,T>,E extends AbstractEntityEditModel,T extends EntityTableModel<E>>
extends Object
implements EntityModel<M,E,T>
A default EntityModel implementation.
-
Field Summary
Fields inherited from interface is.codion.framework.model.EntityModel
USE_CLIENT_PREFERENCES
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultEntityModel
(E editModel) Instantiates a new DefaultEntityModel, without a table modelDefaultEntityModel
(T tableModel) Instantiates a new DefaultEntityModel -
Method Summary
Modifier and TypeMethodDescriptionfinal ValueSetObserver<M>
final <L extends DetailModelLink<M,
E, T>>
LaddDetailModel
(L detailModelLink) Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
final ForeignKeyDetailModelLink<M,
E, T> addDetailModel
(M detailModel) Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
.final ForeignKeyDetailModelLink<M,
E, T> addDetailModel
(M detailModel, ForeignKey foreignKey) Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
Specify the foreign key in case the detail model is based on an entity which contains multiple foreign keys to the same master entity.final void
addDetailModels
(M... detailModels) Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
.final EntityConnection
Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.final EntityConnectionProvider
final boolean
containsDetailModel
(EntityType entityType) final boolean
containsDetailModel
(Class<? extends M> modelClass) final boolean
containsDetailModel
(M detailModel) final boolean
final <C extends M>
CdetailModel
(EntityType entityType) Returns a detail model of the given typefinal <C extends M>
CdetailModel
(Class<C> modelClass) Returns the first detail model of the given typefinal <L extends DetailModelLink<M,
E, T>>
LdetailModelLink
(M detailModel) final Collection<M>
final <C extends E>
Cfinal Entities
entities()
final EntityDefinition
final EntityType
void
Saves any user preferences for this model, its table model and each detail model.final <C extends T>
Cfinal String
toString()
-
Constructor Details
-
DefaultEntityModel
Instantiates a new DefaultEntityModel, without a table model- Parameters:
editModel
- the edit model
-
DefaultEntityModel
Instantiates a new DefaultEntityModel- Parameters:
tableModel
- the table model
-
-
Method Details
-
toString
-
entityType
- Specified by:
entityType
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the type of the entity this entity model is based on
-
connectionProvider
- Specified by:
connectionProvider
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the connection provider used by this entity model
-
connection
Description copied from interface:EntityModel
Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.- Specified by:
connection
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the connection used by this entity model
-
entities
- Specified by:
entities
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the underlying domain entities
-
entityDefinition
- Specified by:
entityDefinition
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the definition of the underlying entity
-
editModel
- Specified by:
editModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
C
- the edit model type- Returns:
- the
EntityEditModel
instance used by thisEntityModel
-
tableModel
- Specified by:
tableModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
C
- the table model type- Returns:
- the
EntityTableModel
-
containsTableModel
public final boolean containsTableModel()- Specified by:
containsTableModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- true if this
EntityModel
contains aEntityTableModel
-
addDetailModels
Description copied from interface:EntityModel
Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
. Note that each detail model is associated with the first foreign key found referencing this models entity.- Specified by:
addDetailModels
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
detailModels
- the detail models to add
-
addDetailModel
Description copied from interface:EntityModel
Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
. Note that the detail model is associated with the first foreign key found referencing this models entity.- Specified by:
addDetailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
detailModel
- the detail model- Returns:
- the resulting
ForeignKeyDetailModelLink
-
addDetailModel
Description copied from interface:EntityModel
Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
Specify the foreign key in case the detail model is based on an entity which contains multiple foreign keys to the same master entity.- Specified by:
addDetailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
detailModel
- the detail modelforeignKey
- the foreign key to base the detail model on- Returns:
- the resulting
ForeignKeyDetailModelLink
-
addDetailModel
Description copied from interface:EntityModel
Adds the given detail model to this model, a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, viaEntityTableModel.conditionRequired()
- Specified by:
addDetailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
L
- theDetailModelLink
type- Parameters:
detailModelLink
- theDetailModelLink
to add- Returns:
- the
DetailModelLink
-
containsDetailModel
- Specified by:
containsDetailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
modelClass
- the detail model class- Returns:
- true if this model contains a detail model of the given class
-
containsDetailModel
- Specified by:
containsDetailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
entityType
- the entityType- Returns:
- true if this model contains a detail model for the given entityType
-
containsDetailModel
- Specified by:
containsDetailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
detailModel
- the detail model- Returns:
- true if this model contains the given detail model
-
detailModels
- Specified by:
detailModels
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- an unmodifiable collection containing the detail models this model contains
-
detailModelLink
- Specified by:
detailModelLink
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
L
- theDetailModelLink
type- Parameters:
detailModel
- the detail model- Returns:
- the link for the given detail model
-
activeDetailModels
- Specified by:
activeDetailModels
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the active detail models, that is, those that should respond to master model events
-
detailModel
Description copied from interface:EntityModel
Returns the first detail model of the given type- Specified by:
detailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
C
- the model type- Parameters:
modelClass
- the type of the requiredEntityModel
- Returns:
- the detail model of type
entityModelClass
-
detailModel
Description copied from interface:EntityModel
Returns a detail model of the given type- Specified by:
detailModel
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
C
- the detail model type- Parameters:
entityType
- the entityType of the required EntityModel- Returns:
- the detail model of type
entityModelClass
-
savePreferences
public void savePreferences()Description copied from interface:EntityModel
Saves any user preferences for this model, its table model and each detail model. Note that ifEntityModel.USE_CLIENT_PREFERENCES
is set to 'false', calling this method has no effect. Remember to call super.savePreferences() when overriding.- Specified by:
savePreferences
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>>
-