Interface EntityEditor.EditorValue<T>
- Type Parameters:
T- the attribute value type
- All Superinterfaces:
Observable<T>,Observer<T>,Value<T>
- Enclosing interface:
EntityEditor
Attribute value in the underlying entity being edited.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePropagates derived attribute values when a source attribute value changes.Nested classes/interfaces inherited from interface is.codion.common.reactive.value.Value
Value.Builder<T,B extends Value.Builder<T, B>>, Value.BuilderFactory, Value.Locked, Value.Notify, Value.Validator<T> -
Method Summary
Modifier and TypeMethodDescriptionReturns theValueinstance controlling the default value supplier for the given attribute.edited()Returns an observer notified each time this value is modified viaValue.set(Object).message()modified()Returns anObservableStateinstance indicating whether the value of the given attribute has been modified.original()persist()Returns aStatecontrolling whether the last used value for this attribute should persist when defaults are set.present()voidpropagate(@Nullable EntityEditor.EditorValue.Propagator<T> propagator) Sets aEntityEditor.EditorValue.Propagatorfor this attribute, which propagates derived values each time this attribute is edited viaValue.set(Object)or set in an entity viaset(Entity, Object).voidrevert()Reverts to the original value if modifiedvoidSets the given value for the underlying attribute in the given entity, applying the associatedEntityEditor.EditorValue.Propagator, if one is specified.valid()voidvalidate()Updates the valid state of this value according to the underlying validatorMethods inherited from interface is.codion.common.reactive.observer.Observable
get, 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, whenMethods inherited from interface is.codion.common.reactive.value.Value
addValidator, changed, clear, link, link, locked, observable, removeValidator, set, unlink, unlink, update, validate
-
Method Details
-
attribute
- Returns:
- the attribute
-
original
- Returns:
- the original value, or the current one if not modified
- See Also:
-
revert
void revert()Reverts to the original value if modified -
validate
void validate()Updates the valid state of this value according to the underlying validator- See Also:
-
persist
State persist()Returns a
Statecontrolling whether the last used value for this attribute should persist when defaults are set.- Returns:
- a
Statecontrolling whether the given attribute value should persist when defaults are set - See Also:
-
valid
ObservableState valid()- Returns:
- an
ObservableStateindicating the valid status of this attribute value.
-
present
ObservableState present()- Returns:
- an
ObservableStateindicating whether the value of this attribute is non-null
-
message
Observable<String> message()- Returns:
- the validation message in case the value is invalid, otherwise the attribute description
-
modified
ObservableState modified()Returns an
ObservableStateinstance indicating whether the value of the given attribute has been modified.Note that only attributes of existing entities are modified, attributes of new, or non-existing entities are never modified.
- Returns:
- an
ObservableStateindicating the modified state of the value of the given attribute - See Also:
-
edited
Returns an observer notified each time this value is modified via
Value.set(Object).This event is NOT triggered when the value changes due to the entity being set via
EntityEditor.EditorEntity.set(Entity),EntityEditor.defaults()orEntityEditor.clear().Note that this event is only triggered if the value actually changes.
- Returns:
- an observer notified when the given attribute value is edited
-
defaultValue
Returns the
Valueinstance controlling the default value supplier for the given attribute.Used when the underlying value is not persistent.
Use
EntityEditor.defaults()to populate the editor with default values.- Returns:
- the
Valueinstance controlling the default value supplier - See Also:
-
propagate
Sets a
EntityEditor.EditorValue.Propagatorfor this attribute, which propagates derived values each time this attribute is edited viaValue.set(Object)or set in an entity viaset(Entity, Object).When this attribute is edited via the editor, the
EntityEditor.EditorValue.Propagatorsets associated values via their respectiveEntityEditor.EditorValueinstances, triggering the usual edit events. When this attribute is set in an entity viaset(Entity, Object), the associated values are set directly on the entity viaEntity.set(Attribute, Object).// Populate billing address fields when customer changes editor().value(Invoice.CUSTOMER_FK).propagate((customer, setter) -> { setter.set(Invoice.BILLINGADDRESS, customer == null ? null : customer.get(Customer.ADDRESS)); setter.set(Invoice.BILLINGCITY, customer == null ? null : customer.get(Customer.CITY)); }); // Decompose a date into constituent parts editor().value(Sample.SAMPLE_DATE).propagate((date, setter) -> { setter.set(Sample.DAY, date == null ? null : date.getDayOfMonth()); setter.set(Sample.MONTH, date == null ? null : date.getMonthValue()); setter.set(Sample.YEAR, date == null ? null : date.getYear()); });- Parameters:
propagator- the propagator, null to remove- See Also:
-
set
Sets the given value for the underlying attribute in the given entity, applying the associated
EntityEditor.EditorValue.Propagator, if one is specified.This method is used by components providing edit functionality outside the editor, such as editable table cells or multi-item editing dialogs, to ensure that derived values are updated along with the primary attribute value.
Note that
valuemay be null.- Parameters:
entity- the entityvalue- the value to set- See Also:
-