Module ultimategdbot.api
Class ValueGetters
- java.lang.Object
-
- com.github.alex1304.ultimategdbot.api.database.guildconfig.ValueGetters
-
public final 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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,discord4j.common.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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,discord4j.common.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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,discord4j.common.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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,Optional<discord4j.common.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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,Optional<discord4j.common.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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,Optional<discord4j.common.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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,discord4j.common.util.Snowflake> idGetter)
Convenient method to generate a value getter for guild channel configuration entries.- Type Parameters:
D
- the type of data object- Parameters:
gateway
- the gateway client 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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,discord4j.common.util.Snowflake> idGetter)
Convenient method to generate a value getter for guild role configuration entries.- Type Parameters:
D
- the type of data object- Parameters:
gateway
- the gateway client 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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,discord4j.common.util.Snowflake> idGetter)
Convenient method to generate a value getter for guild member configuration entries.- Type Parameters:
D
- the type of data object- Parameters:
gateway
- the gateway client 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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,Optional<discord4j.common.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:
gateway
- the gateway client 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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,Optional<discord4j.common.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:
gateway
- the gateway client 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(discord4j.core.GatewayDiscordClient gateway, Function<? super D,Optional<discord4j.common.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:
gateway
- the gateway client 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
-
-