Class UseCaseKey<I,O>

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

public final class UseCaseKey<I,O> extends Object
Type-safe key for use case registration and invocation. Provides compile-time type checking instead of string-based dispatch.

Usage:


 // Define keys as constants
 public interface MyUseCases {
     UseCaseKey<CreateInput, Result<Entity>> CREATE = UseCaseKey.of("create");
     UseCaseKey<String, Result<Entity>> FIND = UseCaseKey.of("find");
 }

 // Use in DSL
 HexaFun.dsl()
     .useCase(MyUseCases.CREATE)
         .validate(...)
         .handle(...)
     .build();

 // Type-safe invocation
 Result<Entity> result = app.invoke(MyUseCases.CREATE, input);
 
  • Method Details

    • of

      public static <I, O> UseCaseKey<I,O> of(String name)
      Create a new type-safe use case key.
      Type Parameters:
      I - The input type
      O - The output type
      Parameters:
      name - The unique name for this use case
      Returns:
      A new UseCaseKey instance
    • name

      public String name()
      Get the string name of this use case key.
      Returns:
      The use case name
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object