Class AbstractListCompositeComponent

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, io.clogr.Clogged, Component, CompositeComponent, Displayable, InfoModel, LabelModel, Model, PresentationModel, DepictedObject
Direct Known Subclasses:
AbstractLayoutComponent

public abstract class AbstractListCompositeComponent extends AbstractMultipleCompositeComponent
Abstract implementation of a composite component that keeps track of its child components in sequence. Iterating over child components is thread safe.
Author:
Garret Wilson
  • Constructor Details

    • AbstractListCompositeComponent

      public AbstractListCompositeComponent(InfoModel infoModel)
      Info model constructor.
      Parameters:
      infoModel - The component info model.
      Throws:
      NullPointerException - if the given info model is null.
  • Method Details

    • getComponentList

      protected List<Component> getComponentList()
      Returns:
      The list of child components.
    • size

      protected int size()
      Returns:
      The number of child components in this component.
    • isEmpty

      protected boolean isEmpty()
      Returns:
      Whether this component contains no child components.
    • contains

      protected boolean contains(Object component)
      Determines whether this component contains the given component.
      Parameters:
      component - The component to check.
      Returns:
      true if this component contains the given component.
    • indexOf

      protected int indexOf(Object component)
      Returns the index in the component of the first occurrence of the specified component.
      Parameters:
      component - The component the index of which should be returned.
      Returns:
      The index in this component of the first occurrence of the specified component, or -1 if this component does not contain the given component.
    • lastIndexOf

      protected int lastIndexOf(Object component)
      Returns the index in this component of the last occurrence of the specified component.
      Parameters:
      component - The component the last index of which should be returned.
      Returns:
      The index in this component of the last occurrence of the specified component, or -1 if this component does not contain the given component.
    • get

      protected Component get(int index)
      Returns the component at the specified index in the component.
      Parameters:
      index - The index of the component to return.
      Returns:
      The component at the specified position in this component.
      Throws:
      IndexOutOfBoundsException - if the index is out of range.
    • addComponent

      protected void addComponent(int index, Component childComponent)
      Adds a child component at the specified index. This version adds the component to the component list. Any class that overrides this method must call this version.
      Parameters:
      index - The index at which the component should be added.
      childComponent - The component to add to this component.
      Throws:
      IllegalArgumentException - if the component already has a parent or if the component is already a child of this composite component.
      IndexOutOfBoundsException - if the index is less than zero or greater than the number of child components.
    • addComponent

      protected final void addComponent(Component childComponent)
      Adds a child component. This version adds the component to the component set. Any class that overrides this method must call this version.

      This version adds the component to the component list.

      Overrides:
      addComponent in class AbstractMultipleCompositeComponent
      Parameters:
      childComponent - The component to add to this component.
    • removeComponent

      protected void removeComponent(Component childComponent)
      Removes a child component. This version removes the component from the component set. Any class that overrides this method must call this version.

      This version removes the component from the component list.

      Overrides:
      removeComponent in class AbstractMultipleCompositeComponent
      Parameters:
      childComponent - The component to remove from this component.
    • getChildComponents

      public Iterable<Component> getChildComponents()
      Specified by:
      getChildComponents in interface CompositeComponent
      Overrides:
      getChildComponents in class AbstractMultipleCompositeComponent
      Returns:
      An iterable to child components.
    • hasChildComponents

      public boolean hasChildComponents()

      This implementation delegates to the component list.

      Specified by:
      hasChildComponents in interface CompositeComponent
      Overrides:
      hasChildComponents in class AbstractMultipleCompositeComponent
      Returns:
      Whether this component has childh components.