Class CodeDelegate

    • Constructor Detail

      • CodeDelegate

        public CodeDelegate()
    • Method Detail

      • log

        public final void log​(LogLevel level,
                              String msg)
        Send a log message.
        Parameters:
        level -
        msg -
      • log

        public final void log​(LogLevel level,
                              Exception ex)
        Send a log message with associated Exception type.
        Parameters:
        level -
        ex -
      • log

        public final void log​(LogLevel level,
                              Exception ex,
                              String msg)
        Send a log message with associated Exception.
        Parameters:
        level -
        ex -
        msg -
      • log

        public final void log​(LogLevel level,
                              Class<? extends Exception> type,
                              String msg)
        Send a log message with associated Exception type.
        Parameters:
        level -
        type -
        msg -
      • isLoggable

        public final boolean isLoggable​(LogLevel level)
        Check whether the messages at the given log level are being sent.
        Parameters:
        level -
        Returns:
      • transmit

        public final void transmit​(String componentID,
                                   String portID,
                                   String value)
        Send a value to a port on another component. The other component must have the same parent.
        Parameters:
        componentID - ID of the other component
        portID - ID of the port on the other component
        value -
      • transmit

        public final void transmit​(String componentID,
                                   String portID,
                                   Value value)
        Send a value to a port on another component. The other component must have the same parent.
        Parameters:
        componentID - ID of the other component
        portID - ID of the port on the other component
        value -
      • transmit

        public final void transmit​(String componentID,
                                   String portID,
                                   double value)
        Send a value to a port on another component. The other component must have the same parent.
        Parameters:
        componentID - ID of the other component
        portID - ID of the port on the other component
        value -
      • tell

        public final void tell​(ControlAddress destination,
                               String value)
        Send a message to a Control.
        Parameters:
        destination - address of control
        value - message value
      • tell

        public final void tell​(ControlAddress destination,
                               double value)
        Send a message to a Control.
        Parameters:
        destination - address of control
        value - message value
      • tell

        public final void tell​(ControlAddress destination,
                               Value value)
        Send a message to a Control.
        Parameters:
        destination - address of control
        value - message value
      • tellIn

        public final void tellIn​(double seconds,
                                 ControlAddress destination,
                                 String value)
        Send a message to a Control in the given number of seconds or fractions of second from now.
        Parameters:
        seconds - from now
        destination - address of control
        value - message value
      • tellIn

        public final void tellIn​(double seconds,
                                 ControlAddress destination,
                                 double value)
        Send a message to a Control in the given number of seconds or fractions of second from now.
        Parameters:
        seconds - from now
        destination - address of control
        value - message value
      • tellIn

        public final void tellIn​(double seconds,
                                 ControlAddress destination,
                                 Value value)
        Send a message to a Control in the given number of seconds or fractions of second from now.
        Parameters:
        seconds - from now
        destination - address of control
        value - message value
      • ask

        public final Async<Call> ask​(ControlAddress destination,
                                     List<Value> args)
        Call a Control. The returned Async result will be completed by the response Call if successful, or the resulting error. Use Call.args to extract the result.
        Parameters:
        destination - address of control
        args - call arguments
        Returns:
        async response
      • ask

        public final Async<Call> ask​(ControlAddress destination,
                                     Object... args)
        Call a Control. The returned Async result will be completed by the response Call if successful, or the resulting error. Use Call.args to extract the result.
        Parameters:
        destination - address of control
        args - call arguments
        Returns:
        async response
      • async

        public final <T,​R> Async<R> async​(T input,
                                                Async.Task<T,​R> task)
        Run a task asynchronously and outside of the component context. All data required to complete the task should be passed in as input data. The task should not access any other data from the component during execution. If multiple inputs are required, consider List.of(java.lang.Object...).

        The returned Async will be completed by the task result, or the resulting error.

        Type Parameters:
        T - type of input
        R - type of result
        Parameters:
        input - input data
        task - async task
        Returns:
        async result
      • self

        public final ComponentAddress self()
        Get this component's address.
        Returns:
        address of self
      • self

        public final ControlAddress self​(String control)
        Get the address of a control on this component.
        Parameters:
        control - id of control
        Returns:
        address of control
      • getLookup

        public Lookup getLookup()
        Return a Lookup for finding instances of features.
        Returns:
        Lookup context
      • find

        public <T> Optional<T> find​(Class<T> type)
        Search for an instance of the given type.
        Type Parameters:
        T -
        Parameters:
        type - class to search for
        Returns:
        Optional wrapping the result if found, or empty if not
      • time

        public final long time()
        The current clocktime in nanoseconds. May only be used relatively to itself, and may be negative.
        Returns:
      • millis

        public final long millis()
        The current time in milliseconds since the root was started.
        Returns: