Class ChangedProperty<T extends Serializable>

  • Type Parameters:
    T - The type of the inner elements in case of a collection-based property.

    public class ChangedProperty<T extends Serializable>
    extends Object
    Class to track property changes. The property is specified as a constant having a contstant string as name and optional inner elements. The inner elements allow to track changes to collection-based properties.

    The equality of changed properties only refers to the type (the constant string) of the changed property, the inner elements are ignored. This allows for simple handling in the tracking objects. Changed properties need not and are not valid without the corresponding tracking object.

    Tracking of inner elements is kept simple and done via side-effects. That is, the tracking object may keep a reference to the corresponding map or retrieve it via getChangedInnerElements(). Make sure to never put null into the map!
    To prevent unwanted behaviour, tracking elements should drop changed properties as soon as they are provided to the outside world. Usually, retrieving changed properties also includes resetting them (by creating new data structures for tracking).

    Author:
    Ulrich Kreher
    • Constructor Detail

      • ChangedProperty

        public ChangedProperty​(String property)
        Creates a new changed property of the designated type without tracking inner elements.
        Parameters:
        property - The (type of the) changed property.
      • ChangedProperty

        public ChangedProperty​(String property,
                               Map<T,​ChangeType> changedInnerElements)
        Creates a new changed property of the designated type with the designated map tracking inner elements. Note that the map may be changed by side-effects from outside this class.
        Parameters:
        property - The (type of the) changed property.
        changedInnerElements - The map of all inner elements of the property that have changed, for instance indexes into a list of values.
    • Method Detail

      • getProperty

        public String getProperty()
        Gets the (type of the) changed property.
        Returns:
        The (type of the) changed property.
      • getChangedInnerElements

        public Map<T,​ChangeType> getChangedInnerElements()
        Gets the map of all inner elements of the property that have changed, for instance indexes into a list of values. An empty map indicates that no inner elements have changed, null is used for properties that do not have inner elements or of which inner elements are not tracked.
        Returns:
        The map of all inner elements of the property that have changed. An empty map indicates that no inner elements have changed, null is used for properties that do not have inner elements or of which inner elements are not tracked.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object