Class Matcher


  • public class Matcher
    extends java.lang.Object
    The matcher uses the matching definition as provided by StateMatcher to match against the state generated by subscribing a source of that state

    param: currentStateSource source of the state which needs to be matched against the current state specified in state matcher param: stateMatcher the matcher definition to execute

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<MatcherResponse> jStart()
      Start the matching process from Java application
      scala.concurrent.Future<MatcherResponse> start()
      Start the matching process
      void stop()
      Abort the stream of subscribed state in case matching is no longer required.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • jStart

        public java.util.concurrent.CompletableFuture<MatcherResponse> jStart()
        Start the matching process from Java application

        Returns:
        the result of matching as a CompletableFuture of MatcherResponse
      • start

        public scala.concurrent.Future<MatcherResponse> start()
        Start the matching process

        Returns:
        the result of matching as a Future value of MatcherResponse
      • stop

        public void stop()
        Abort the stream of subscribed state in case matching is no longer required. Eg. when composing operations in command execution, the matching was started before knowing the actual result of validation and the validation failed.

        
           val matcherResponseF: Future[MatcherResponse] = matcher.start
           
           val eventualCommandResponse: Future[CommandResponse] = async {
           val initialResponse = await(assemblyComponent.oneway(setupWithMatcher))
           initialResponse match {
           case _: Accepted ⇒
           val matcherResponse = await(matcherResponseF)
           matcherResponse match {
           case MatchCompleted  ⇒ Completed(setupWithMatcher.runId)
           case MatchFailed(ex) ⇒ Error(setupWithMatcher.runId, ex.getMessage)
           }
           case invalid: Invalid ⇒
           matcher.stop()
           invalid
           case x ⇒ x
           }