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
ConstructorsConstructorDescriptionDefaultEntityApplicationModel
(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 EntityConnectionProvider
final boolean
containsEntityModel
(EntityType entityType) final boolean
containsEntityModel
(Class<? extends M> modelClass) final boolean
containsEntityModel
(M entityModel) final boolean
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 modelvoid
Saves any user preferences.final User
user()
version()
final State
-
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
-
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
-
warnAboutUnsavedData
- Specified by:
warnAboutUnsavedData
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- the State controlling whether this model warns about unsaved data
- See Also:
-
containsUnsavedData
public final boolean containsUnsavedData()- Specified by:
containsUnsavedData
in interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>> - Returns:
- true if any edit model associated with this application model contains modified and unsaved data, that is, existing entities that have been modified but not saved
-
savePreferences
public void savePreferences()Description copied from interface:EntityApplicationModel
Saves any user preferences. 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 interfaceEntityApplicationModel<M extends DefaultEntityModel<M,
E, T>, E extends AbstractEntityEditModel, T extends EntityTableModel<E>>
-