Interface InteractionControllerInstantiator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface InteractionControllerInstantiator

An InteractionControllerInstantiator is used get instances of classes annotated with Interaction, if needed creating those.

At the time of Runtime creation, forRuntime(String, JDA) is called, allowing the InteractionControllerInstantiator to provide an instance that has not to be thread safe and is bound to one Runtime.

Please also note that per Runtime there can be multiple classes annotated with Interaction but there can be only one instance per class of those per Runtime. Instances of interactions should be treated like runtime scoped singletons, so to speak.

  • Method Details

    • instance

      <T> T instance(Class<T> clazz, InteractionControllerInstantiator.Context context)
      This method will be called each time an instance of a class annotated with Interaction is needed.
      Parameters:
      clazz - the Class of needed instance
      context - a context that gives additional useful information or provide some needed functionality
    • forRuntime

      default InteractionControllerInstantiator forRuntime(String id, net.dv8tion.jda.api.JDA jda)
      Called each time a new Runtime is created.
      Parameters:
      id - the runtime id
      jda - the JDA instance associated with the event responsible for creating the new Runtime instance
      Returns:
      a specific instance of InteractionControllerInstantiator belonging to provided runtime.