Class MapTreeWriter

java.lang.Object
org.praxislive.base.MapTreeWriter
All Implemented Interfaces:
TreeWriter

public final class MapTreeWriter extends Object implements TreeWriter
A TreeWriter implementation that builds the data in the format specified by
invalid reference
SerializableProtocol
.
  • Constructor Details

    • MapTreeWriter

      public MapTreeWriter()
      Create a new writer.
  • Method Details

    • writeAnnotation

      public MapTreeWriter writeAnnotation(String key, String value)
      Description copied from interface: TreeWriter
      Write a custom annotation.
      Specified by:
      writeAnnotation in interface TreeWriter
      Parameters:
      key - annotation id
      value - annotation value
      Returns:
      this writer
    • writeChild

      public MapTreeWriter writeChild(String id, Consumer<TreeWriter> processor)
      Description copied from interface: TreeWriter
      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.

      Specified by:
      writeChild in interface TreeWriter
      Parameters:
      id - child ID
      processor - writer consumer to process and write child
      Returns:
      this writer
    • writeConnection

      public MapTreeWriter writeConnection(Connection connection)
      Description copied from interface: TreeWriter
      Write a port connection between two child component.
      Specified by:
      writeConnection in interface TreeWriter
      Parameters:
      connection - port connection
      Returns:
      this writer
    • writeInfo

      public MapTreeWriter writeInfo(ComponentInfo info)
      Description copied from interface: TreeWriter
      Write the component info.
      Specified by:
      writeInfo in interface TreeWriter
      Parameters:
      info - component info
      Returns:
      this writer
    • writeProperty

      public MapTreeWriter writeProperty(String id, Value value)
      Description copied from interface: TreeWriter
      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.

      Specified by:
      writeProperty in interface TreeWriter
      Parameters:
      id -
      value -
      Returns:
      this writer
    • writeType

      public MapTreeWriter writeType(ComponentType type)
      Description copied from interface: TreeWriter
      Write the component type.
      Specified by:
      writeType in interface TreeWriter
      Parameters:
      type - component type
      Returns:
      this writer
    • build

      public PMap build()
      Build the data map.
      Returns:
      data map
    • clear

      public MapTreeWriter clear()
      Clear the writer for reuse.
      Returns:
      this writer