Class AttemptModifier<T>

    • Constructor Detail

      • AttemptModifier

        public AttemptModifier​(int attempts,
                               Predicate<T> validator,
                               Consumer<IPlatformActor<?>> messageSupplier)
        Creates a new AttemptModifier
        Parameters:
        attempts - number of allowed attempts
        validator - the input validator
        messageSupplier - the "try again" message sender function
      • AttemptModifier

        public AttemptModifier​(int attempts,
                               Predicate<T> validator)
        Creates a new AttemptModifier
        Parameters:
        attempts - number of allowed attempts
        validator - the input validator
    • Method Detail

      • attempt

        public boolean attempt​(T input)
        Accepts input and validates it using the valdiator Predicate
        Parameters:
        input - the provided input
        Returns:
        if the attempt was valid or not
      • sendMessage

        public final void sendMessage​(IPlatformActor<?> actor)
        Sends a "try again" message to the actor
        Parameters:
        actor - the actor that should receive the message