Class Descriptor<T extends Descriptor<T>>

java.lang.Object
org.praxislive.code.Descriptor<T>
Type Parameters:
T - direct subtype
Direct Known Subclasses:
ControlDescriptor, PortDescriptor, ReferenceDescriptor

public abstract sealed class Descriptor<T extends Descriptor<T>> extends Object permits ReferenceDescriptor<T>, ControlDescriptor<T>, PortDescriptor<T>
Common interface of reference, port and control descriptors.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Descriptor(Class<T> type, String id)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    attach(CodeContext<?> context, T previous)
    Attach the descriptor to the provided context.
    void
    Hook called when the descriptor is disposed, when the code context is changing or the component is being removed.
    final String
    id()
    Get the descriptor ID.
    void
    Hook called when the descriptor becomes part of an active code context, or after anything triggers a reset while active.
    void
    Hook called when the code context becomes inactive, including on context swap, or if anything else triggers a reset while active.
    void
    Hook called when the code context becomes active due to the execution context state changing.
    void
    Hook called when the code context becomes inactive due to the execution context state changing.
    void
    write(TreeWriter writer)
    Write properties or annotations as part of serialization of the component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Descriptor

      protected Descriptor(Class<T> type, String id)
  • Method Details

    • id

      public final String id()
      Get the descriptor ID.
      Returns:
      id
    • attach

      public abstract void attach(CodeContext<?> context, T previous)
      Attach the descriptor to the provided context. The previous descriptor with the same ID and type is provided, if it exists. The implementation should handle disposal of the previous descriptor if required.

      The onInit() hook will be called after attachment if the code context is active, or when the code context becomes active.

      Parameters:
      context - code context
      previous - previous descriptor or null
    • onInit

      public void onInit()
      Hook called when the descriptor becomes part of an active code context, or after anything triggers a reset while active. The default implementation does nothing.
    • onStart

      public void onStart()
      Hook called when the code context becomes active due to the execution context state changing. The onInit() hook will have been called prior to this hook. The default implementation does nothing.
    • onStop

      public void onStop()
      Hook called when the code context becomes inactive due to the execution context state changing. This hook will be called before the onReset() hook. The default implementation does nothing.
    • onReset

      public void onReset()
      Hook called when the code context becomes inactive, including on context swap, or if anything else triggers a reset while active. The default implementation does nothing.
    • dispose

      public void dispose()
      Hook called when the descriptor is disposed, when the code context is changing or the component is being removed. This hook is not called by default when a descriptor is passed in as the previous instance in attach(org.praxislive.code.CodeContext, org.praxislive.code.Descriptor). The default implementation does nothing.
    • write

      public void write(TreeWriter writer)
      Write properties or annotations as part of serialization of the component. The default implementation does nothing.
      Parameters:
      writer - component tree writer