Interface Container

All Superinterfaces:
Component, Lookup.Provider
All Known Implementing Classes:
AbstractContainer, AbstractContainer.Delegate, AbstractRootContainer, CodeContainer, CodeRootContainer

public interface Container extends Component, Lookup.Provider
Extension to the Component interface for components that can contain other components as children.
  • Method Details

    • getChild

      Component getChild(String id)
      Get child component with specific ID.
      Parameters:
      id -
      Returns:
      Component, or null if no component with that ID exists.
    • children

      Stream<String> children()
      Get a Stream of the child IDs that this container makes publicly visible. Containers may have hidden children that can be returned from getChild(java.lang.String) but are not listed here. All IDs returned should correspond to valid components, and (if provided) match the implementation of ContainerProtocol.

      A Stream is returned allowing flexibility in implementation.

      Returns:
      stream of public child IDs
    • getAddress

      ComponentAddress getAddress(Component child)
      Get the address for the provided child component, or null if the component is not a child of this container.
      Parameters:
      child - component
      Returns:
      address, or null of component is not a child of this container.
    • write

      default void write(TreeWriter writer)
      If supported, write the state of this container to the provided TreeWriter. This should allow for the container, and its children, to be recreated in as close to its current state as possible.

      To fully support this method, the Container should write its type, component info, property values, children and connections, in that order. It may also add custom annotations.

      The default implementation of this method does nothing.

      Specified by:
      write in interface Component
      Parameters:
      writer - TreeWriter to write to
    • getType

      default ComponentType getType(Component child)
      Get the ComponentType of the provided child. The default implementation looks for ComponentInfo.KEY_COMPONENT_TYPE in the child's info. Container's may override to provide a more efficient or suitable result.

      The default implementation does not check if the provided component is actually a child of this container.

      Parameters:
      child - child component
      Returns:
      component type, or null if unavailable