Interface EventGraph<Event>

Type Parameters:
Event - The type of event to be stored in the graph structure.
All Superinterfaces:
EffectExpression<Event>
All Known Implementing Classes:
EventGraph.Atom, EventGraph.Concurrently, EventGraph.Empty, EventGraph.Sequentially

public sealed interface EventGraph<Event> extends EffectExpression<Event> permits EventGraph.Empty<Event>, EventGraph.Atom<Event>, EventGraph.Sequentially<Event>, EventGraph.Concurrently<Event>
An immutable tree-representation of a graph of sequentially- and concurrently-composed events.

An event graph is a series-parallel graph whose edges represent atomic events. Event graphs may be composed sequentially (in series) or concurrently (in parallel).

As with many recursive tree-like structures, an event graph is utilized by accepting an EffectTrait visitor and traversing the series-parallel structure recursively. This trait provides methods for each type of node in the tree representation (empty, sequential composition, and parallel composition). For each node, the trait combines the results from its children into a result that will be provided to the same trait at the node's parent. The result of the traversal is the value computed by the trait at the root node.

Different domains may interpret each event differently, and so evaluate the same event graph under different projections. An event may have no particular effect in one domain, while being critically important to another domain.

See Also:
  • EffectTrait
  • Method Details

    • evaluate

      default <Effect> Effect evaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Effect> trait, Function<Event,Effect> substitution)
      Description copied from interface: EffectExpression
      Produce an effect in the domain of effects described by the provided trait and event substitution.
      Specified by:
      evaluate in interface EffectExpression<Event>
      Type Parameters:
      Effect - The type of effect produced by the visitor.
      Parameters:
      trait - A visitor to be used to compose effects in sequence or concurrently.
      substitution - A visitor to be applied at any atomic events.
      Returns:
      The effect described by this object, within the provided domain of effects.
    • empty

      static <Event> EventGraph<Event> empty()
      Create an empty event graph.
      Type Parameters:
      Event - The type of event that might be contained by this event graph.
      Returns:
      An empty event graph.
    • atom

      static <Event> EventGraph<Event> atom(Event atom)
      Create an event graph consisting of a single atomic event.
      Type Parameters:
      Event - The type of the given atomic event.
      Parameters:
      atom - An atomic event.
      Returns:
      An event graph consisting of a single atomic event.
    • sequentially

      static <Event> EventGraph<Event> sequentially(EventGraph<Event> prefix, EventGraph<Event> suffix)
      Create an event graph by combining multiple event graphs of the same type in sequence.
      Type Parameters:
      Event - The type of atomic event contained by these graphs.
      Parameters:
      prefix - The first event graph to apply.
      suffix - The second event graph to apply.
      Returns:
      An event graph consisting of a sequence of subgraphs.
    • concurrently

      static <Event> EventGraph<Event> concurrently(EventGraph<Event> left, EventGraph<Event> right)
      Create an event graph by combining multiple event graphs of the same type in parallel.
      Type Parameters:
      Event - The type of atomic event contained by these graphs.
      Parameters:
      left - An event graph to apply concurrently.
      right - An event graph to apply concurrently.
      Returns:
      An event graph consisting of a set of concurrent subgraphs.
    • sequentially

      static <Event> EventGraph<Event> sequentially(List<EventGraph<Event>> segments)
      Create an event graph by combining multiple event graphs of the same type in sequence.
      Type Parameters:
      Event - The type of atomic event contained by these graphs.
      Parameters:
      segments - A series of event graphs to combine in sequence.
      Returns:
      An event graph consisting of a sequence of subgraphs.
    • concurrently

      static <Event> EventGraph<Event> concurrently(Collection<EventGraph<Event>> branches)
      Create an event graph by combining multiple event graphs of the same type in parallel.
      Type Parameters:
      Event - The type of atomic event contained by these graphs.
      Parameters:
      branches - A set of event graphs to combine in parallel.
      Returns:
      An event graph consisting of a set of concurrent subgraphs.
    • sequentially

      @SafeVarargs static <Event> EventGraph<Event> sequentially(EventGraph<Event>... segments)
      Create an event graph by combining multiple event graphs of the same type in sequence.
      Type Parameters:
      Event - The type of atomic event contained by these graphs.
      Parameters:
      segments - A series of event graphs to combine in sequence.
      Returns:
      An event graph consisting of a sequence of subgraphs.
    • concurrently

      @SafeVarargs static <Event> EventGraph<Event> concurrently(EventGraph<Event>... branches)
      Create an event graph by combining multiple event graphs of the same type in parallel.
      Type Parameters:
      Event - The type of atomic event contained by these graphs.
      Parameters:
      branches - A set of event graphs to combine in parallel.
      Returns:
      An event graph consisting of a set of concurrent subgraphs.