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.
-
Constructor Summary
ConstructorDescriptionDefaultEntityModel
(E editModel) Instantiates a new DefaultEntityModel, without a table modelDefaultEntityModel
(T tableModel) Instantiates a new DefaultEntityModel -
Method Summary
Modifier and TypeMethodDescriptionfinal <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()
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, viaEntityQueryModel.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, 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.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, viaEntityQueryModel.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
final ValueSetObserver<M>
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, viaEntityQueryModel.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, viaEntityQueryModel.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, 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.- 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, viaEntityQueryModel.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
-
linkedDetailModels
- Specified by:
linkedDetailModels
in interfaceEntityModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- detail models with an active link to this model, that is, those that should respond to master model events
- See Also:
-
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
-