Interface TreeWriter

All Known Implementing Classes:
MapTreeWriter

public interface TreeWriter
Interface for writing the configuration and state of a Component, or tree of components, into a data structure.

A Component should write its type, component info and properties to the writer, in that order. A Container should additionally write its children and connections. Arbitrary annotations may be added.

The format and completeness of the output data is not specified.

  • Method Details

    • writeType

      TreeWriter writeType(ComponentType type)
      Write the component type.
      Parameters:
      type - component type
      Returns:
      this writer
    • writeInfo

      TreeWriter writeInfo(ComponentInfo info)
      Write the component info.
      Parameters:
      info - component info
      Returns:
      this writer
    • writeAnnotation

      TreeWriter writeAnnotation(String key, String value)
      Write a custom annotation.
      Parameters:
      key - annotation id
      value - annotation value
      Returns:
      this writer
    • writeProperty

      TreeWriter writeProperty(String id, Value value)
      Write the value of a property.

      A component may write properties that are at their defaults if this is more efficient. Consumers of the resulting data may verify against the provided info.

      Parameters:
      id -
      value -
      Returns:
      this writer
    • writeChild

      TreeWriter writeChild(String id, Consumer<TreeWriter> processor)
      Write the data for a child component.

      The processor will be called during the execution of this method. The passed in writer may be the same writer, configured to refer to the child, or a new writer instance. The writer should not be cached or used outside of the processor.

      Parameters:
      id - child ID
      processor - writer consumer to process and write child
      Returns:
      this writer
    • writeConnection

      TreeWriter writeConnection(Connection connection)
      Write a port connection between two child component.
      Parameters:
      connection - port connection
      Returns:
      this writer