Interface EffectExpression<Event>

Type Parameters:
Event - The type of abstract effect in this expression.
All Known Subinterfaces:
EventGraph<Event>
All Known Implementing Classes:
EventGraph.Atom, EventGraph.Concurrently, EventGraph.Empty, EventGraph.Sequentially

public interface EffectExpression<Event>
Declares the ability of an object to be evaluated under an EffectTrait.

Effect expressions describe a series-parallel graph of abstract effects called "events". The EventGraph class is a concrete realization of this idea. However, if the expression is immediately consumed after construction, the EventGraph imposes construction of needless intermediate data. Producers of effects will typically want to return a custom implementor of this class that will directly produce the desired expression for a given EffectTrait.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <Effect> Effect
    evaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Effect> trait, Function<Event,Effect> substitution)
    Produce an effect in the domain of effects described by the provided trait and event substitution.
    default Event
    evaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Event> trait)
    Produce an effect in the domain of effects described by the provided EffectTrait.
    default <TargetType>
    EffectExpression<TargetType>
    map(Function<Event,TargetType> transformation)
    Transform abstract effects without evaluating the expression.
    default <TargetType>
    EffectExpression<TargetType>
    substitute(Function<Event,EffectExpression<TargetType>> transformation)
    Replace abstract effects with sub-expressions over other abstract effects.
  • Method Details

    • evaluate

      <Effect> Effect evaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Effect> trait, Function<Event,Effect> substitution)
      Produce an effect in the domain of effects described by the provided trait and event substitution.
      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.
    • evaluate

      default Event evaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Event> trait)
      Produce an effect in the domain of effects described by the provided EffectTrait.
      Parameters:
      trait - A visitor to be used to compose effects in sequence or concurrently.
      Returns:
      The effect described by this object, within the provided domain of effects.
    • map

      default <TargetType> EffectExpression<TargetType> map(Function<Event,TargetType> transformation)
      Transform abstract effects without evaluating the expression.

      This is a functorial "map" operation.

      Type Parameters:
      TargetType - The type of abstract effect in the result expression.
      Parameters:
      transformation - A transformation to be applied to each event.
      Returns:
      An equivalent expression over a different set of events.
    • substitute

      default <TargetType> EffectExpression<TargetType> substitute(Function<Event,EffectExpression<TargetType>> transformation)
      Replace abstract effects with sub-expressions over other abstract effects.

      This is analogous to composing functions f(x) = x + x and x(t) = 2*t to obtain (f.g)(t) = 2*t + 2*t. For example, for an expression x; y, we may substitute 1 | 2 for x and 3 for y, yielding (1 | 2); 3.

      This is a monadic "bind" operation.

      Type Parameters:
      TargetType - The type of abstract effect in the result expression.
      Parameters:
      transformation - A transformation from events to effect expressions.
      Returns:
      An equivalent expression over a different set of events.