Interface EntityEditor.EditorEntity
- All Superinterfaces:
Observable<Entity>,Observer<Entity>
- Enclosing interface:
EntityEditor<R extends EntityEditor<R>>
-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.common.reactive.observer.Observer
Observer.Builder<T,B extends Observer.Builder<T, B>> -
Method Summary
Modifier and TypeMethodDescriptionchanging()Throwing aCancelExceptionfrom a listener will cancel the change.get()voidrefresh()Refreshes the active Entity from the database, discarding all changes.voidSilently replaces the editor entity values without firingchanging()orchangedevents; onlyreplaced()fires.replaced()Returns an observer notified each time the entity is replaced viareplace(Entity).voidPopulates this editor entity with the values from the given entity or sets the default value for all attributes in case it is null.Methods inherited from interface is.codion.common.reactive.observer.Observable
changed, getOrThrow, getOrThrow, is, isNot, isNull, isNullable, optionalMethods inherited from interface is.codion.common.reactive.observer.Observer
addConsumer, addListener, addWeakConsumer, addWeakListener, observer, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener, when, when
-
Method Details
-
get
Entity get()- Specified by:
getin interfaceObservable<Entity>- Returns:
- an immutable copy of the entity being edited
-
set
Populates this editor entity with the values from the given entity or sets the default value for all attributes in case it is null.
Use
EntityEditor.EditorValues.clear()in order to clear the editor of all values.Notifies that the entity is about to change via
changing(), then notifies change viaObserver.observer(). Detail editors registered viaEntityEditor.DetailEditors.add(EditorLink)are reloaded via their link's load action. This is the master-selection path — usereplace(Entity)for silent post-persist refreshes that should not re-fire change events.For master editors with registered detail editors, the order is bottom-up:
changing()fires before the detail subtree is touched; the detail subtree is then set; finallychangedfires once every detail editor is in its post-set state. This makeschangedthe "everything done" signal for the full master/detail tree, suitable for actions that need to inspect aggregate state.- Parameters:
entity- the entity to set, if null, then defaults are set- Throws:
IllegalArgumentException- in case the entity is not of the correct type- See Also:
-
changing
Throwing a
CancelExceptionfrom a listener will cancel the change.For master editors with registered detail editors, this fires before the detail subtree is set, allowing listeners to inspect the pre-change state of the entire master/detail tree. The post-change counterpart is
changed.- Returns:
- an observer notified each time the entity is about to be changed via
set(Entity)orEntityEditor.EditorValues.defaults(). - See Also:
-
replaced
Returns an observer notified each time the entity is replaced via
replace(Entity).For master editors with registered detail editors, this fires after the detail subtree has been replaced — by the time listeners run, every detail editor is in its post-persist state. This makes
replaced()the "everything done" signal for the full master/detail tree, suitable for actions that need to inspect aggregate state (e.g., focusing the first empty detail editor, or adjusting which detail editors are visible).- Returns:
- an observer notified each time the entity is replaced via
replace(Entity)
-
replace
Silently replaces the editor entity values without firing
changing()orchangedevents; onlyreplaced()fires. A null argument sets default values.If the new entity has the same primary key as the current one (the typical post-persist refresh case), detail editors are not touched — their state is owned by their own persist tasks. If the primary key changes (including null↔non-null transitions), detail editors are reloaded via their link's load action, since the master's identity has changed.
- Parameters:
entity- the replacement entity, or null to set defaults- See Also:
-
refresh
void refresh()Refreshes the active Entity from the database, discarding all changes. If the active Entity is new then calling this method has no effect.- See Also:
-