Class AbstractListHolderStateObject<T extends StateObject>

    • Constructor Detail

      • AbstractListHolderStateObject

        protected AbstractListHolderStateObject​(StateObject parent)
        Creates a new AbstractListHolderStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
      • AbstractListHolderStateObject

        protected AbstractListHolderStateObject​(StateObject parent,
                                                java.util.List<? extends T> items)
        Creates a new AbstractListHolderStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        items - The list of StateObjects to add as children to this one
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
      • AbstractListHolderStateObject

        protected AbstractListHolderStateObject​(StateObject parent,
                                                T... items)
        Creates a new AbstractListHolderStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        items - The list of StateObjects to add as children to this one
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
    • Method Detail

      • addListChangeListener

        public void addListChangeListener​(java.lang.String listName,
                                          IListChangeListener<T> listener)
        Registers the given IListChangeListener for the specified list. The listener will be notified only when items are added, removed, moved from the list.
        Specified by:
        addListChangeListener in interface ListHolderStateObject<T extends StateObject>
        Parameters:
        listName - The name of the list for which the listener will be notified when the content of the list has changed
        listener - The listener to be notified upon changes
      • areChildrenEquivalent

        protected boolean areChildrenEquivalent​(AbstractListHolderStateObject<? extends StateObject> stateObject)
        Determines whether the children of this StateObject are equivalent to the children of the given one, i.e. the information of the StateObjects is the same.
        Parameters:
        stateObject - The StateObject to compare its children to this one's children
        Returns:
        true if both have equivalent children; false otherwise
      • canMoveDown

        public boolean canMoveDown​(T stateObject)
        Determines whether the given StateObject can be moved down by one position in the list owned by its parent.
        Specified by:
        canMoveDown in interface ListHolderStateObject<T extends StateObject>
        Parameters:
        stateObject - The StateObject that could potentially be moved down
        Returns:
        true if the object can be moved down by one unit; false otherwise
      • canMoveUp

        public boolean canMoveUp​(T stateObject)
        Determines whether the given StateObject can be moved up by one position in the list owned by its parent.
        Specified by:
        canMoveUp in interface ListHolderStateObject<T extends StateObject>
        Parameters:
        stateObject - The StateObject that could potentially be moved up
        Returns:
        true if the object can be moved up by one unit; false otherwise
      • listName

        protected abstract java.lang.String listName()
        Returns the name that is uniquely identifying the list.
        Returns:
        The unique name identifying the list
      • removeListChangeListener

        public void removeListChangeListener​(java.lang.String listName,
                                             IListChangeListener<T> listener)
        Unregisters the given IListChangeListener that was registered for the specified list. The listener will no longer be notified only when items are added, removed, moved from the list.
        Specified by:
        removeListChangeListener in interface ListHolderStateObject<T extends StateObject>
        Parameters:
        listName - The name of the list for which the listener was registered
        listener - The listener to unregister
      • toStringItems

        protected void toStringItems​(java.lang.Appendable writer,
                                     boolean useComma)
                              throws java.io.IOException
        Adds to the given writer a crude string representation of the children of this one.
        Parameters:
        writer - The writer used to print out the string representation
        useComma - Determines whether a comma should be added after each item, except after the last one
        Throws:
        java.io.IOException - This should never happens, only required because Appendable is used instead of StringBuilder for instance