Class CodeContainer<D extends CodeContainerDelegate>

java.lang.Object
org.praxislive.code.CodeComponent<D>
org.praxislive.code.CodeContainer<D>
Type Parameters:
D - wrapped delegate base type
All Implemented Interfaces:
Component, Container, Lookup.Provider

public class CodeContainer<D extends CodeContainerDelegate> extends CodeComponent<D> implements Container
A CodeContainer is a Container instance that is rewritable at runtime. The CodeContainer itself remains constant, but passes most responsibility to a CodeContainer.Context wrapping a CodeContainerDelegate (user code). This component handles switching from one context to the next. A CodeComponent cannot be created directly - see CodeFactory.

The CodeContainer supports a property for proxying ports of child components on to the parent. This is automatically added when the CodeContainerDelegate.ProxyPorts annotation is used on the init() method of the delegate.

  • Method Details

    • children

      public Stream<String> children()
      Description copied from interface: Container
      Get a Stream of the child IDs that this container makes publicly visible. Containers may have hidden children that can be returned from Container.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.

      Specified by:
      children in interface Container
      Returns:
      stream of public child IDs
    • getAddress

      public ComponentAddress getAddress(Component child)
      Description copied from interface: Container
      Get the address for the provided child component, or null if the component is not a child of this container.
      Specified by:
      getAddress in interface Container
      Parameters:
      child - component
      Returns:
      address, or null of component is not a child of this container.
    • getChild

      public Component getChild(String id)
      Description copied from interface: Container
      Get child component with specific ID.
      Specified by:
      getChild in interface Container
      Parameters:
      id -
      Returns:
      Component, or null if no component with that ID exists.
    • getInfo

      public ComponentInfo getInfo()
      Description copied from interface: Component
      Get the ComponentInfo object for this component.
      Specified by:
      getInfo in interface Component
      Overrides:
      getInfo in class CodeComponent<D extends CodeContainerDelegate>
      Returns:
      ComponentInfo
    • getPort

      public Port getPort(String id)
      Description copied from interface: Component
      Get the Port with the given ID, or null if it does not exist.
      Specified by:
      getPort in interface Component
      Overrides:
      getPort in class CodeComponent<D extends CodeContainerDelegate>
      Parameters:
      id -
      Returns:
      Port or null
    • getLookup

      public Lookup getLookup()
      Description copied from interface: Lookup.Provider
      Get the Lookup from this Provider.
      Specified by:
      getLookup in interface Lookup.Provider
      Returns:
      lookup
    • hierarchyChanged

      public void hierarchyChanged()
      Description copied from interface: Component
      Notify the component that a change has happened in its component hierarchy. For example its direct parent or an ancestor has changed. This method will be called after parentNotify() if the result of an immediate parent change.
      Specified by:
      hierarchyChanged in interface Component
      Overrides:
      hierarchyChanged in class CodeComponent<D extends CodeContainerDelegate>
    • write

      public void write(TreeWriter writer)
      Description copied from interface: Component
      If supported, write the state of this component to the provided TreeWriter. This should allow for the component to be recreated in as close to its current state as possible.

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

      The component should delegate to Container.getType(org.praxislive.core.Component) to find its type rather than relying directly on ComponentInfo.KEY_COMPONENT_TYPE.

      The default implementation of this method does nothing.

      Specified by:
      write in interface Component
      Specified by:
      write in interface Container
      Overrides:
      write in class CodeComponent<D extends CodeContainerDelegate>
      Parameters:
      writer - TreeWriter to write to