Module is.codion.framework.model
Package is.codion.framework.model
Class AbstractEntityApplicationModel<M extends EntityModel<M,E,T,R>,E extends EntityEditModel<R>,T extends EntityTableModel<E,R>,R extends EntityEditor<R>>
java.lang.Object
is.codion.framework.model.AbstractEntityApplicationModel<M,E,T,R>
- Type Parameters:
M- theEntityModeltypeE- theEntityEditModeltypeT- theEntityTableModeltypeR- theEntityEditortype
- All Implemented Interfaces:
EntityApplicationModel<M,,E, T, R> AutoCloseable
- Direct Known Subclasses:
SwingEntityApplicationModel
public abstract class AbstractEntityApplicationModel<M extends EntityModel<M,E,T,R>,E extends EntityEditModel<R>,T extends EntityTableModel<E,R>,R extends EntityEditor<R>>
extends Object
implements EntityApplicationModel<M,E,T,R>
An abstract
EntityApplicationModel implementation.-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.framework.model.EntityApplicationModel
EntityApplicationModel.EntityModels<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> -
Field Summary
Fields inherited from interface is.codion.framework.model.EntityApplicationModel
PREFERENCES_KEY, USER_PREFERENCES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEntityApplicationModel(EntityConnection connection, User user, Collection<? extends M> entityModels) Instantiates a new AbstractEntityApplicationModelprotectedAbstractEntityApplicationModel(EntityConnection connection, Collection<? extends M> entityModels) Instantiates a new AbstractEntityApplicationModel -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this model along with itsEntityApplicationModel.connection(), after which neither can be used.final EntityConnectionReturns theEntityConnectionused by this application model, a single self-managing instance shared by all its entity models: it validates the underlying connection before each operation and re-establishes it when it has gone bad, so it is safe to hold on to and use for the lifetime of the application, seeEntityConnection.builder().final Entitiesentities()final EntityApplicationModel.EntityModels<M, E, T, R> models()voidrestore(Preferences preferences) Restores the model-owned persistent state of this application's model tree from the given preferences node.voidstore(Preferences preferences) Stores the model-owned persistent state of this application's model tree to the given preferences node.final Useruser()Note that this user may differ from the connection user, which is reachable viaconnection().user()
-
Constructor Details
-
AbstractEntityApplicationModel
protected AbstractEntityApplicationModel(EntityConnection connection, Collection<? extends M> entityModels) Instantiates a new AbstractEntityApplicationModel- Parameters:
connection- the EntityConnection instanceentityModels- the entity models- Throws:
NullPointerException- in case connection is null
-
AbstractEntityApplicationModel
protected AbstractEntityApplicationModel(EntityConnection connection, User user, Collection<? extends M> entityModels) Instantiates a new AbstractEntityApplicationModel- Parameters:
connection- the EntityConnection instanceuser- the application user, in case it differs from the connection userentityModels- the entity models- Throws:
NullPointerException- in case connection is null
-
-
Method Details
-
user
Description copied from interface:EntityApplicationModelNote that this user may differ from the connection user, which is reachable viaconnection().user()- Specified by:
userin interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> - Returns:
- the application user
-
connection
Description copied from interface:EntityApplicationModelReturns the
EntityConnectionused by this application model, a single self-managing instance shared by all its entity models: it validates the underlying connection before each operation and re-establishes it when it has gone bad, so it is safe to hold on to and use for the lifetime of the application, seeEntityConnection.builder().- Specified by:
connectionin interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> - Returns:
- the connection used by this application model
-
entities
- Specified by:
entitiesin interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> - Returns:
- the underlying domain entities
-
models
- Specified by:
modelsin interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> - Returns:
- the
EntityApplicationModel.EntityModels
-
store
Description copied from interface:EntityApplicationModelStores the model-owned persistent state of this application's model tree to the given preferences node. Each root model stores its state under a child node named by itsEntityModel.preferencesKey(). May be overridden to persist custom state, in which casesuper.store(preferences)should be called in order to retain the default state.Custom state belongs in a child node of its own, named so as not to clash with a model's preferences key.
- Specified by:
storein interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> - Parameters:
preferences- the preferences node representing the entity models- See Also:
-
restore
Description copied from interface:EntityApplicationModelRestores the model-owned persistent state of this application's model tree from the given preferences node. Each root model restores its state from a child node named by itsEntityModel.preferencesKey().- Specified by:
restorein interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> - Parameters:
preferences- the preferences node representing the entity models- See Also:
-
close
public void close()Description copied from interface:EntityApplicationModelCloses this model along with itsEntityApplicationModel.connection(), after which neither can be used. Closing it again has no effect.A UI calls this as the application exits, once the exit can no longer be cancelled and the preferences have been stored. It may block, closing a remote connection for example logging out.
Override to release what a model holds, before calling super, as it may depend on the connection.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEntityApplicationModel<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>>
-