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 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, that is, if the current value differs from its default value.original()persist()Returns aStatecontrolling whether the last used value for this attribute should persist when defaults are set.present()<V> voidAdds a propagation mapping from this attribute to the given attribute.voidrevert()Reverts to the original value if modifiedvoidSets the given value for the underlying attribute in the given entity, applying the associated propagators, if any are specified.valid()voidvalidate()Updates the valid state of this value according to the underlying validatorMethods inherited from interface is.codion.common.reactive.observer.Observable
changed, 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, 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, that is, if the current value differs from its default value.Note that unlike
EntityEditor.modified()this state does not depend on whether the underlying entity exists.- 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.EditorValues.defaults()orEntityEditor.EditorValues.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.EditorValues.defaults()to populate the editor with default values.- Returns:
- the
Valueinstance controlling the default value supplier - See Also:
-
propagate
Adds a propagation mapping from this attribute to the given attribute. Each time this attribute is edited via
Value.set(Object)or set in an entity viaset(Entity, Object), the function is applied to derive the target attribute value.When editing via the editor, derived values are set via their respective
EntityEditor.EditorValueinstances, triggering edit events. When setting values in an entity, derived values are set directly on the entity viaEntity.set(Attribute, Object).Multiple propagations can be added for a single source attribute.
// Populate billing address fields when customer changes editor().value(Invoice.CUSTOMER_FK).propagate(Invoice.BILLINGADDRESS, customer -> customer == null ? null : customer.get(Customer.ADDRESS)); editor().value(Invoice.CUSTOMER_FK).propagate(Invoice.BILLINGCITY, customer -> customer == null ? null : customer.get(Customer.CITY)); // Decompose a date into constituent parts editor().value(Sample.SAMPLE_DATE).propagate(Sample.DAY, date -> date == null ? null : date.getDayOfMonth()); editor().value(Sample.SAMPLE_DATE).propagate(Sample.MONTH, date -> date == null ? null : date.getMonthValue());- Type Parameters:
V- the target attribute value type- Parameters:
attribute- the target attribute to propagate toderiver- the function deriving the target value from this attribute's value
-
set
Sets the given value for the underlying attribute in the given entity, applying the associated propagators, if any are 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:
-