Interface TerminalAccess

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

The app's single answer to "who may watch" and "who may type".

As a lambda it answers the first question only: typing stays denied unless inputSink(TerminalCaller, String) is overridden.

  • Method Details

    • canWatch

      boolean canWatch(TerminalCaller caller, String terminalId)
      Whether the caller may watch the terminal.

      A typist must also be able to watch.

      Parameters:
      caller - Who is asking.
      terminalId - The terminal id.
      Returns:
      true if the caller may watch it.
    • inputSink

      default Optional<TerminalSink> inputSink(TerminalCaller caller, String terminalId)
      The sink the caller may type into.

      Input also requires canWatch(TerminalCaller, String): a sink returned for a caller who may not watch is still denied.

      Parameters:
      caller - Who is asking.
      terminalId - The terminal id.
      Returns:
      The sink, or empty when typing is denied. Empty by default.