Class ConditionEvaluationLogger

  • All Implemented Interfaces:
    ConditionEvaluationListener<java.lang.Object>

    public class ConditionEvaluationLogger
    extends java.lang.Object
    implements ConditionEvaluationListener<java.lang.Object>
    Simple implementation of ConditionEvaluationListener that prints the condition evaluation results to the console using System.out.println by default. You can customize the how the results are written by providing a custom consumer that prints the results.
    • Field Detail

      • logPrinter

        private final java.util.function.Consumer<java.lang.String> logPrinter
      • unit

        private final java.util.concurrent.TimeUnit unit
    • Constructor Detail

      • ConditionEvaluationLogger

        public ConditionEvaluationLogger()
        Uses TimeUnit.MILLISECONDS as unit for elapsed and remaining time.
      • ConditionEvaluationLogger

        public ConditionEvaluationLogger​(java.util.function.Consumer<java.lang.String> logPrinter)
        Specifies a consumer that is responsible for actually printing the logs
        Parameters:
        logPrinter - The logger to use
      • ConditionEvaluationLogger

        public ConditionEvaluationLogger​(java.util.concurrent.TimeUnit unit)
        Specifies the TimeUnit to use as unit for elapsed and remaining time.
        Parameters:
        unit - The time unit to use.
      • ConditionEvaluationLogger

        public ConditionEvaluationLogger​(java.util.function.Consumer<java.lang.String> logPrinter,
                                         java.util.concurrent.TimeUnit unit)
    • Method Detail

      • beforeEvaluation

        public void beforeEvaluation​(StartEvaluationEvent<java.lang.Object> condition)
        Description copied from interface: ConditionEvaluationListener
        Handle the startEvaluationEvent. Method is default to keep the ConditionEvaluationListener backward compatible.
        Specified by:
        beforeEvaluation in interface ConditionEvaluationListener<java.lang.Object>
        Parameters:
        condition - the event containing various properties of the condition evaluation to be started
      • onTimeout

        public void onTimeout​(TimeoutEvent timeoutEvent)
        Description copied from interface: ConditionEvaluationListener
        Handle the timeoutEvent. Method is default to keep the ConditionEvaluationListener backward compatible.
        Specified by:
        onTimeout in interface ConditionEvaluationListener<java.lang.Object>
        Parameters:
        timeoutEvent - the event containing some properties about the condition evaluation timeout
      • exceptionIgnored

        public void exceptionIgnored​(IgnoredException ignoredException)
        Description copied from interface: ConditionEvaluationListener
        Handle ignored exception that get thrown while condition evaluation. Method is default to keep the ConditionEvaluationListener backward compatible.
        Specified by:
        exceptionIgnored in interface ConditionEvaluationListener<java.lang.Object>
        Parameters:
        ignoredException - contains the ignored Throwable and various properties of the evaluation
      • conditionEvaluationLogger

        public static ConditionEvaluationLogger conditionEvaluationLogger​(java.util.function.Consumer<java.lang.String> logger)
        Syntactic sugar to avoid writing the new keyword in Java. Uses TimeUnit.MILLISECONDS as unit for elapsed and remaining time.
        Returns:
        A new instance of ConditionEvaluationLogger
      • conditionEvaluationLogger

        public static ConditionEvaluationLogger conditionEvaluationLogger()
        Syntactic sugar to avoid writing the new keyword in Java. Uses TimeUnit.MILLISECONDS as unit for elapsed and remaining time.
        Returns:
        A new instance of ConditionEvaluationLogger
      • conditionEvaluationLogger

        public static ConditionEvaluationLogger conditionEvaluationLogger​(java.util.concurrent.TimeUnit unit)
        Syntactic sugar to avoid writing the new keyword in Java. Specifies the TimeUnit to use as unit for elapsed and remaining time.
        Parameters:
        unit - The time unit to use.