Interface EntityEditor.EditorEntity

All Superinterfaces:
Observable<Entity>, Observer<Entity>, Sensor
Enclosing interface:
EntityEditor<R extends EntityEditor<R>>

public static interface EntityEditor.EditorEntity extends Observable<Entity>
Provides access to the entity instance being edited.

A new editor starts out holding a null valued entity, not a defaulted one — present() reports no value for every attribute, including those specifying a default value. Applying the defaults is left to whatever presents the editor, which calls defaults() once it is set up to edit a new record, as the Swing edit panel and the Android edit view both do on construction. The editor can not do so itself: a default value supplied via EntityEditor.EditorValue.defaultValue() is resolved when the defaults are applied, and the edit model must have had the chance to configure those first.

Its consumers receive the entity the editor holds once it has changed, as get() returns it: the one set via set(Entity), or the defaulted or cleared one after defaults() or clear(), never null. Whether it is an existing entity or a new one is told by Entity.exists(), or by this editor's exists() where its predicate has been replaced, up to date when the consumers are notified.

When the entity changes as a whole, via set(Entity), replace(Entity), defaults() or clear(), the editor holds every new value before any is notified, the values which changed being notified one at a time, in the order of the attributes. An edit made while they are notified is ignored, so setting an entity never modifies it, whether the edit comes from a component still showing a value from the previous entity, a combo box filtered by an earlier value clearing its selection for example, or from a consumer of one value setting another. Such a consumer reacts to edits via EntityEditor.EditorValue.edited(), and to the entity having been set via this editor entity's consumers, notified once every value has been.

See Also: