Class AttributeChanges

java.lang.Object
io.jmix.core.event.AttributeChanges

public class AttributeChanges extends Object
An object describing changes in entity attributes.
See Also:
  • Method Details

    • getOwnAttributes

      public Set<String> getOwnAttributes()
      Returns names of changed attributes for the root entity.
    • getAttributes

      public Set<String> getAttributes()
      Returns names of changed attributes for the root entity and all its embedded entities (if any). Embedded attributes are represented by dot-separated paths.
    • isChanged

      public boolean isChanged(String attributeName)
      Returns true if an attribute with the given name is changed. If the attribute is not changed or does not exist at all, returns false.
    • getOldValue

      @Nullable public <T> T getOldValue(String attributeName)
      Returns old value of a changed attribute with the given name. Old value can be null. If the attribute is not changed or does not exist at all, returns null.

      If the attribute is a reference to an entity, its old value is of type Id. If the attribute is a collection of references, its old value is a collection of Ids.

    • getOldReferenceId

      @Nullable public <E> Id<E> getOldReferenceId(String attributeName)
      Type-safe method of getting the old value of a reference attribute.
      Parameters:
      attributeName - reference attribute name
      Returns:
      Id of the referenced object
    • getOldCollection

      public <E> Collection<Id<E>> getOldCollection(String attributeName, Class<E> entityClass)
      Type-safe method of getting the old value of a collection attribute.

      Usage example:

       Collection<Id<OrderLine, UUID>> orderLines = event.getChanges().getOldCollection("orderLines", OrderLine.class);
       for (Id<OrderLine> orderLineId : orderLines) {
           OrderLine orderLine = dataManager.load(orderLineId).one();
           // ...
       }
       
      Parameters:
      attributeName - collection attribute name
      entityClass - class of the attribute
      Returns:
      collection of Ids
    • hasChanges

      public boolean hasChanges()
      Returns:
      true if changes is not empty
    • toString

      public String toString()
      Overrides:
      toString in class Object