Module is.codion.framework.model
Package is.codion.framework.model
Class DefaultEntityApplicationModel<M extends DefaultEntityModel<M,E,T>,E extends AbstractEntityEditModel,T extends EntityTableModel<E>>
java.lang.Object
is.codion.framework.model.DefaultEntityApplicationModel<M,E,T>
- Type Parameters:
M
- the type ofDefaultEntityModel
this application model is based onE
- the type ofAbstractEntityEditModel
used by thisEntityModel
T
- the type ofEntityTableModel
used by thisEntityModel
- All Implemented Interfaces:
EntityApplicationModel<M,
E, T>
- Direct Known Subclasses:
SwingEntityApplicationModel
public class DefaultEntityApplicationModel<M extends DefaultEntityModel<M,E,T>,E extends AbstractEntityEditModel,T extends EntityTableModel<E>>
extends Object
implements EntityApplicationModel<M,E,T>
A central application model class.
-
Field Summary
Fields inherited from interface is.codion.framework.model.EntityApplicationModel
AUTHENTICATION_REQUIRED, SAVE_DEFAULT_USERNAME, USERNAME_PREFIX
-
Constructor Summary
ConstructorDescriptionDefaultEntityApplicationModel
(EntityConnectionProvider connectionProvider) Instantiates a new DefaultEntityApplicationModelDefaultEntityApplicationModel
(EntityConnectionProvider connectionProvider, Version version) Instantiates a new DefaultEntityApplicationModel -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addEntityModel
(M entityModel) Adds the given entity model to this modelfinal void
addEntityModels
(M... entityModels) Adds the given entity models to this model.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
containsEntityModel
(EntityType entityType) final boolean
containsEntityModel
(Class<? extends M> modelClass) final boolean
containsEntityModel
(M entityModel) final Entities
entities()
final <C extends M>
CentityModel
(EntityType entityType) final <C extends M>
CentityModel
(Class<C> modelClass) final void
refresh()
Refreshes all data models contained in this application modelfinal User
user()
version()
-
Constructor Details
-
DefaultEntityApplicationModel
Instantiates a new DefaultEntityApplicationModel- Parameters:
connectionProvider
- the EntityConnectionProvider instance- Throws:
NullPointerException
- in case connectionProvider is null
-
DefaultEntityApplicationModel
Instantiates a new DefaultEntityApplicationModel- Parameters:
connectionProvider
- the EntityConnectionProvider instanceversion
- the application version- Throws:
NullPointerException
- in case connectionProvider is null
-
-
Method Details
-
user
- Specified by:
user
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the current user
-
connectionProvider
- Specified by:
connectionProvider
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the EntityConnectionProvider instance being used by this EntityApplicationModel
-
connection
Description copied from interface:EntityApplicationModel
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 interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the connection used by this application model
-
version
- Specified by:
version
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the application version, an empty Optional in case no version information is available
-
entities
- Specified by:
entities
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the underlying domain entities
-
addEntityModels
Description copied from interface:EntityApplicationModel
Adds the given entity models to this model.- Specified by:
addEntityModels
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
entityModels
- the entity models to add
-
addEntityModel
Description copied from interface:EntityApplicationModel
Adds the given entity model to this model- Specified by:
addEntityModel
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
entityModel
- the detail model
-
containsEntityModel
- Specified by:
containsEntityModel
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
modelClass
- the application model class- Returns:
- true if this model contains a EntityModel instance of the given class
-
containsEntityModel
- Specified by:
containsEntityModel
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
entityType
- the entityType- Returns:
- true if this model contains a EntityModel for the given entityType
-
containsEntityModel
- Specified by:
containsEntityModel
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Parameters:
entityModel
- the entity model- Returns:
- true if this model contains the given EntityModel
-
entityModels
- Specified by:
entityModels
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- an unmodifiable List containing the EntityModel instances contained in this EntityApplicationModel
-
refresh
public final void refresh()Description copied from interface:EntityApplicationModel
Refreshes all data models contained in this application model- Specified by:
refresh
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>>
-
entityModel
- Specified by:
entityModel
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
C
- the model type- Parameters:
modelClass
- the model class- Returns:
- the EntityModel of the given type
-
entityModel
- Specified by:
entityModel
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Type Parameters:
C
- the model type- Parameters:
entityType
- the entityType- Returns:
- the EntityModel based on the given entityType
-