Module is.codion.framework.model
Package is.codion.framework.model
Interface EntityModel<M extends EntityModel<M,E,T>,E extends EntityEditModel,T extends EntityTableModel<E>>
- Type Parameters:
M
- the type ofEntityModel
used for detail modelsE
- the type ofEntityEditModel
used by thisEntityModel
T
- the type ofEntityTableModel
used by thisEntityModel
- All Known Implementing Classes:
DefaultEntityModel
,SwingEntityModel
public interface EntityModel<M extends EntityModel<M,E,T>,E extends EntityEditModel,T extends EntityTableModel<E>>
Specifies a class responsible for, among other things, coordinating a
EntityEditModel
and an EntityTableModel
.-
Method Summary
Modifier and TypeMethodDescription<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, viaEntityQueryModel.conditionRequired()
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, viaEntityQueryModel.conditionRequired()
.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, viaEntityQueryModel.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.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, viaEntityQueryModel.conditionRequired()
.Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.boolean
containsDetailModel
(EntityType entityType) boolean
containsDetailModel
(Class<? extends M> modelClass) boolean
containsDetailModel
(M detailModel) boolean
<C extends M>
CdetailModel
(EntityType entityType) Returns a detail model of the given type<C extends M>
CdetailModel
(Class<C> modelClass) Returns the first detail model of the given type<L extends DetailModelLink<M,
E, T>>
LdetailModelLink
(M detailModel) <C extends E>
Centities()
<C extends T>
C
-
Method Details
-
entityType
EntityType entityType()- Returns:
- the type of the entity this entity model is based on
-
connectionProvider
EntityConnectionProvider connectionProvider()- Returns:
- the connection provider used by this entity model
-
connection
EntityConnection connection()Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.- Returns:
- the connection used by this entity model
-
entities
Entities entities()- Returns:
- the underlying domain entities
-
entityDefinition
EntityDefinition entityDefinition()- Returns:
- the definition of the underlying entity
-
editModel
- Type Parameters:
C
- the edit model type- Returns:
- the
EntityEditModel
instance used by thisEntityModel
-
tableModel
- Type Parameters:
C
- the table model type- Returns:
- the
EntityTableModel
- Throws:
IllegalStateException
- in case no table model is available
-
containsTableModel
boolean containsTableModel()- Returns:
- true if this
EntityModel
contains aEntityTableModel
-
linkedDetailModels
ValueSetObserver<M> linkedDetailModels()- Returns:
- detail models with an active link to this model, that is, those that should respond to master model events
- See Also:
-
addDetailModels
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, viaEntityQueryModel.conditionRequired()
. Note that each detail model is associated with the first foreign key found referencing this models entity.- Parameters:
detailModels
- the detail models to add- Throws:
IllegalArgumentException
- in case no foreign key exists between the entities involved
-
addDetailModel
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, viaEntityQueryModel.conditionRequired()
. Note that the detail model is associated with the first foreign key found referencing this models entity.- Parameters:
detailModel
- the detail model- Returns:
- the resulting
ForeignKeyDetailModelLink
- Throws:
IllegalArgumentException
- in case no foreign key exists between the entities involved
-
addDetailModel
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, viaEntityQueryModel.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.- Parameters:
detailModel
- the detail modelforeignKey
- the foreign key to base the detail model on- Returns:
- the resulting
ForeignKeyDetailModelLink
-
addDetailModel
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, viaEntityQueryModel.conditionRequired()
- Type Parameters:
L
- theDetailModelLink
type- Parameters:
detailModelLink
- theDetailModelLink
to add- Returns:
- the
DetailModelLink
- Throws:
IllegalArgumentException
- in case the model has already been added
-
containsDetailModel
- Parameters:
modelClass
- the detail model class- Returns:
- true if this model contains a detail model of the given class
-
containsDetailModel
- Parameters:
entityType
- the entityType- Returns:
- true if this model contains a detail model for the given entityType
-
containsDetailModel
- Parameters:
detailModel
- the detail model- Returns:
- true if this model contains the given detail model
-
detailModel
Returns the first detail model of the given type- Type Parameters:
C
- the model type- Parameters:
modelClass
- the type of the requiredEntityModel
- Returns:
- the detail model of type
entityModelClass
- Throws:
IllegalArgumentException
- in case this model does not contain a detail model of the given type
-
detailModel
Returns a detail model of the given type- Type Parameters:
C
- the detail model type- Parameters:
entityType
- the entityType of the required EntityModel- Returns:
- the detail model of type
entityModelClass
- Throws:
IllegalArgumentException
- in case this model does not contain a detail model for the entityType
-
detailModels
Collection<M> detailModels()- Returns:
- an unmodifiable collection containing the detail models this model contains
-
detailModelLink
- Type Parameters:
L
- theDetailModelLink
type- Parameters:
detailModel
- the detail model- Returns:
- the link for the given detail model
- Throws:
IllegalArgumentException
- in case this model does not contain the given detail model
-