Module ultimategdbot.api
Class ValueGetters
- java.lang.Object
-
- com.github.alex1304.ultimategdbot.api.guildconfig.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.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.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.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.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.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.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.
-
-
-
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 objectT
- 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 objectT
- 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 channelidGetter
- 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 roleidGetter
- 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 memberidGetter
- 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 channelidGetter
- 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 roleidGetter
- 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 memberidGetter
- a Function that gets the member ID from the data object- Returns:
- a value getter for a guild member
-
-