Interface Resolver<T>

Type Parameters:
T - the type to resolve
All Known Implementing Classes:
ComponentResolver, DataObjectResolver, EmojiResolver, I18n, JsonResolver, MessageResolver, PlaceholderResolver

public interface Resolver<T>

Common interface for all resolvers of JDA-Commands.

A Resolver takes an arbitrary object and transforms it to a state, where it can be sent to the Discord API. For instance, the MessageResolver will take a String as input and then apply placeholders, localization and resolve any emoji references. Other Resolver implementations are responsible for more complex objects, like components.

Most Resolvers are not intended to be directly used by end users but part of the public api to allow manual execution of the frameworks resolving logic for dynamic values if needed.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The priority of this resolver influences the order in which resolver are applied in a resolution pipeline.
    default T
    resolve(T object, Locale locale, Entry... placeholders)
    Resolves the given object for the provided locale.
    resolve(T object, Locale locale, Map<String, @Nullable Object> placeholders)
    Resolves the given object for the provided locale.
    default T
    resolve(T object, DiscordLocale locale, Entry... placeholders)
    Resolves the given object for the provided locale.
    default T
    resolve(T object, DiscordLocale locale, Map<String, @Nullable Object> placeholders)
    Resolves the given object for the provided locale.
  • Method Details

    • resolve

      T resolve(T object, Locale locale, Map<String, @Nullable Object> placeholders)
      Resolves the given object for the provided locale.
      Parameters:
      object - the object to resolve
      locale - the Locale to use for localization
      placeholders - the placeholders to use if supported by the used localization system
      Returns:
      the resolved object
    • resolve

      default T resolve(T object, Locale locale, Entry... placeholders)
      Resolves the given object for the provided locale.
      Parameters:
      object - the object to resolve
      locale - the Locale to use for localization
      placeholders - the placeholders to use if supported by the used localization system
      Returns:
      the resolved object
    • resolve

      default T resolve(T object, DiscordLocale locale, Map<String, @Nullable Object> placeholders)
      Resolves the given object for the provided locale.
      Parameters:
      object - the object to resolve
      locale - the DiscordLocale to use for localization
      placeholders - the placeholders to use if supported by the used localization system
      Returns:
      the resolved object
    • resolve

      default T resolve(T object, DiscordLocale locale, Entry... placeholders)
      Resolves the given object for the provided locale.
      Parameters:
      object - the object to resolve
      locale - the DiscordLocale to use for localization
      placeholders - the placeholders to use if supported by the used localization system
      Returns:
      the resolved object
    • priority

      int priority()

      The priority of this resolver influences the order in which resolver are applied in a resolution pipeline.

      Currently, this only applies to Resolver<String>, when using MessageResolver (as JDA-Commands does internally). Generally speaking, resolvers with lower priority run first.

      If the priority isn't important (e.g. for ComponentResolver) this should return 0.

      Returns:
      the priority of this resolver