Class UseCaseValidationStep<I>

java.lang.Object
com.guinetik.hexafun.hexa.UseCaseValidationStep<I>
Type Parameters:
I - The input type of the use case

public class UseCaseValidationStep<I> extends Object
Builder step for defining validation and handler logic.

Supports chaining multiple validators that execute in order:


 .useCase(Keys.ADD)
     .validate(Validators::validateCounter)
     .validate(Validators::validateAmount)
     .handle(input -> ...)
 
  • Constructor Details

  • Method Details

    • validate

      public UseCaseValidationStep<I> validate(ValidationPort<I> validator)
      Add another validator to the chain. Validators execute in order; first failure short-circuits.
      Parameters:
      validator - The next validation port
      Returns:
      This step for further chaining
    • handle

      public <O> UseCaseBuilder handle(UseCase<I,Result<O>> handler)
      Define the handler that runs after all validators pass.
      Type Parameters:
      O - The output type of the handler
      Parameters:
      handler - The use case logic that processes the validated input
      Returns:
      The builder for chaining more use cases