Class ValueGetters


  • public class ValueGetters
    extends Object
    Utility class that provides factories for guild configuration value getters. It allows the use of method references on data objects, by hiding the fact that a value is asynchronous.
    • Method Detail

      • forSimpleValue

        public static <D extends GuildConfigData<D>,​T> Function<D,​reactor.core.publisher.Mono<T>> forSimpleValue​(Function<? super D,​? extends T> getter)
        Convenient method to generate a value getter for simple value-based configuration entries.
        Type Parameters:
        D - the type of data object
        T - the type of value to get
        Parameters:
        getter - a Function that gets the value from the data object, typically a method reference
        Returns:
        a value getter for a simple value
      • forOptionalValue

        public static <D extends GuildConfigData<D>,​T> Function<D,​reactor.core.publisher.Mono<T>> forOptionalValue​(Function<? super D,​Optional<? extends T>> getter)
        Convenient method to generate a value getter for optional value-based configuration entries.
        Type Parameters:
        D - the type of data object
        T - the type of value to get
        Parameters:
        getter - a Function that gets the optional value from the data object, typically a method reference
        Returns:
        a value getter for an optional value
      • forGuildChannel

        public static <D extends GuildConfigData<D>> Function<D,​reactor.core.publisher.Mono<discord4j.core.object.entity.channel.GuildChannel>> forGuildChannel​(Bot bot,
                                                                                                                                                                      Function<? super D,​discord4j.rest.util.Snowflake> idGetter)
        Convenient method to generate a value getter for guild channel configuration entries.
        Type Parameters:
        D - the type of data object
        Parameters:
        bot - the bot instance to use to retrieve the channel
        idGetter - a Function that gets the channel ID from the data object
        Returns:
        a value getter for a guild channel
      • forGuildRole

        public static <D extends GuildConfigData<D>> Function<D,​reactor.core.publisher.Mono<discord4j.core.object.entity.Role>> forGuildRole​(Bot bot,
                                                                                                                                                   Function<? super D,​discord4j.rest.util.Snowflake> idGetter)
        Convenient method to generate a value getter for guild role configuration entries.
        Type Parameters:
        D - the type of data object
        Parameters:
        bot - the bot instance to use to retrieve the role
        idGetter - a Function that gets the role ID from the data object
        Returns:
        a value getter for a guild role
      • forGuildMember

        public static <D extends GuildConfigData<D>> Function<D,​reactor.core.publisher.Mono<discord4j.core.object.entity.Member>> forGuildMember​(Bot bot,
                                                                                                                                                       Function<? super D,​discord4j.rest.util.Snowflake> idGetter)
        Convenient method to generate a value getter for guild member configuration entries.
        Type Parameters:
        D - the type of data object
        Parameters:
        bot - the bot instance to use to retrieve the member
        idGetter - a Function that gets the member ID from the data object
        Returns:
        a value getter for a guild member
      • forOptionalGuildChannel

        public static <D extends GuildConfigData<D>> Function<D,​reactor.core.publisher.Mono<discord4j.core.object.entity.channel.GuildChannel>> forOptionalGuildChannel​(Bot bot,
                                                                                                                                                                              Function<? super D,​Optional<discord4j.rest.util.Snowflake>> idGetter)
        Convenient method to generate a value getter for guild channel configuration entries. This handles the case where the channel is optional.
        Type Parameters:
        D - the type of data object
        Parameters:
        bot - the bot instance to use to retrieve the channel
        idGetter - a Function that gets the channel ID from the data object
        Returns:
        a value getter for a guild channel
      • forOptionalGuildRole

        public static <D extends GuildConfigData<D>> Function<D,​reactor.core.publisher.Mono<discord4j.core.object.entity.Role>> forOptionalGuildRole​(Bot bot,
                                                                                                                                                           Function<? super D,​Optional<discord4j.rest.util.Snowflake>> idGetter)
        Convenient method to generate a value getter for guild role configuration entries. This handles the case where the role is optional.
        Type Parameters:
        D - the type of data object
        Parameters:
        bot - the bot instance to use to retrieve the role
        idGetter - a Function that gets the role ID from the data object
        Returns:
        a value getter for a guild role
      • forOptionalGuildMember

        public static <D extends GuildConfigData<D>> Function<D,​reactor.core.publisher.Mono<discord4j.core.object.entity.Member>> forOptionalGuildMember​(Bot bot,
                                                                                                                                                               Function<? super D,​Optional<discord4j.rest.util.Snowflake>> idGetter)
        Convenient method to generate a value getter for guild member configuration entries. This handles the case where the member is optional.
        Type Parameters:
        D - the type of data object
        Parameters:
        bot - the bot instance to use to retrieve the member
        idGetter - a Function that gets the member ID from the data object
        Returns:
        a value getter for a guild member