Interface EntityEditModel.EditableEntity

All Superinterfaces:
is.codion.common.observer.Mutable<is.codion.framework.domain.entity.Entity>, is.codion.common.observer.Observable<is.codion.framework.domain.entity.Entity>, is.codion.common.observer.Observer<is.codion.framework.domain.entity.Entity>
Enclosing interface:
EntityEditModel

public static interface EntityEditModel.EditableEntity extends is.codion.common.observer.Mutable<is.codion.framework.domain.entity.Entity>
Provides access to the active entity being edited.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Indicates whether the active entity exists in the database.
    static interface 
    Indicates whether the active entity is modified.
  • Method Summary

    Modifier and Type
    Method
    Description
    is.codion.common.observer.Observer<is.codion.framework.domain.entity.Entity>
     
    void
    Clears all values from the underlying entity, disregarding the EntityEditModel.EditableValue.persist() directive.
    void
    Populates this edit model with default values for all attributes.
    is.codion.common.state.StateObserver
     
     
    is.codion.common.state.StateObserver
    isNotNull(is.codion.framework.domain.entity.attribute.Attribute<?> attribute)
     
    is.codion.common.state.StateObserver
    isNull(is.codion.framework.domain.entity.attribute.Attribute<?> attribute)
     
    Returns a StateObserver indicating whether any values have been modified.
    boolean
    nullable(is.codion.framework.domain.entity.attribute.Attribute<?> attribute)
     
    is.codion.common.state.StateObserver
     
    void
    Refreshes the active Entity from the database, discarding all changes.
    void
    Reverts all attribute value changes.
    void
    set(is.codion.framework.domain.entity.Entity entity)
    Sets the given entity or defaults if null.
    is.codion.common.state.StateObserver
     
    void
    Validates the current state of the entity
    is.codion.common.value.Value<is.codion.framework.domain.entity.EntityValidator>
    Controls the validator used by this edit model.
    value(is.codion.framework.domain.entity.attribute.Attribute<T> attribute)
    Returns the EntityEditModel.EditableValue instance representing attribute in this EntityEditModel.EditableEntity.
    is.codion.common.observer.Observer<is.codion.framework.domain.entity.attribute.Attribute<?>>
    Returns an observer notified each time a value changes, either via its associated EntityEditModel.EditableValue instance or when the entity is set via Mutable.set(Object) or defaults().

    Methods inherited from interface is.codion.common.observer.Observable

    addConsumer, addListener, addWeakConsumer, addWeakListener, get, observer, optional, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
  • Method Details

    • set

      void set(is.codion.framework.domain.entity.Entity entity)
      Sets the given entity or defaults if null. Use clear() in order to clear the entity of all values.
      Specified by:
      set in interface is.codion.common.observer.Mutable<is.codion.framework.domain.entity.Entity>
      Parameters:
      entity - the entity to set, if null, then defaults are set
    • clear

      void clear()
      Clears all values from the underlying entity, disregarding the EntityEditModel.EditableValue.persist() directive.
      Specified by:
      clear in interface is.codion.common.observer.Mutable<is.codion.framework.domain.entity.Entity>
    • defaults

      void defaults()
      Populates this edit model with default values for all attributes.
      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.
    • revert

      void revert()
      Reverts all attribute value changes.
    • exists

      Returns:
      a StateObserver indicating whether the entity exists in the database
      See Also:
    • modified

      Returns a StateObserver indicating whether any values have been modified.
      Returns:
      a StateObserver indicating the modified state of this entity
      See Also:
    • edited

      is.codion.common.state.StateObserver edited()
      Returns:
      a StateObserver indicating whether the entity has been edited, that is, exists and is modified
      See Also:
    • changing

      is.codion.common.observer.Observer<is.codion.framework.domain.entity.Entity> changing()
      Returns:
      an observer notified each time the entity is about to be changed via Mutable.set(Object) or defaults()
      See Also:
    • valueChanged

      is.codion.common.observer.Observer<is.codion.framework.domain.entity.attribute.Attribute<?>> valueChanged()
      Returns an observer notified each time a value changes, either via its associated EntityEditModel.EditableValue instance or when the entity is set via Mutable.set(Object) or defaults().
      Returns:
      an observer notified each time a value changes
    • isNull

      is.codion.common.state.StateObserver isNull(is.codion.framework.domain.entity.attribute.Attribute<?> attribute)
      Parameters:
      attribute - the attribute
      Returns:
      a StateObserver indicating whether the value of the given attribute is null
    • isNotNull

      is.codion.common.state.StateObserver isNotNull(is.codion.framework.domain.entity.attribute.Attribute<?> attribute)
      Parameters:
      attribute - the attribute
      Returns:
      a StateObserver indicating whether the value of the given attribute is not null
    • primaryKeyNull

      is.codion.common.state.StateObserver primaryKeyNull()
      Returns:
      a StateObserver indicating whether the primary key of the entity is null
    • valid

      is.codion.common.state.StateObserver valid()
      Returns:
      a StateObserver indicating the valid status of the underlying Entity.
      See Also:
    • validator

      is.codion.common.value.Value<is.codion.framework.domain.entity.EntityValidator> validator()
      Controls the validator used by this edit model.
      Returns:
      the Value controlling the validator
      See Also:
    • validate

      void validate()
      Validates the current state of the entity
      Throws:
      is.codion.framework.domain.entity.exception.ValidationException - in case the entity is invalid
    • nullable

      boolean nullable(is.codion.framework.domain.entity.attribute.Attribute<?> attribute)
      Parameters:
      attribute - the attribute
      Returns:
      true if this value is allowed to be null according to the validator
      See Also:
    • value

      <T> EntityEditModel.EditableValue<T> value(is.codion.framework.domain.entity.attribute.Attribute<T> attribute)
      Returns the EntityEditModel.EditableValue instance representing attribute in this EntityEditModel.EditableEntity.
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      Returns:
      the EntityEditModel.EditableValue representing the given attribute