Interface DatabaseOutputFunction<D>
- All Superinterfaces:
java.util.function.BiFunction<D,java.lang.Long,reactor.core.publisher.Mono<java.lang.String>>
public interface DatabaseOutputFunction<D>
extends java.util.function.BiFunction<D,java.lang.Long,reactor.core.publisher.Mono<java.lang.String>>
Function that determines the string to display to the user after reading the value from teh database.
-
Method Summary
Static Methods Modifier and Type Method Description static <D> DatabaseOutputFunction<D>
from(java.util.function.Function<? super D,java.lang.String> converter)
Forwards the value from the database by returning its string representation provided by the given function.static DatabaseOutputFunction<java.lang.Long>
fromChannelId(Bot bot)
Reads the database value as a channel ID, attempts to convert it to a channel and gives a string representation of this channel provided byDiscordFormatter.formatGuildChannel(GuildChannel)
.static DatabaseOutputFunction<java.lang.Long>
fromChannelId(Bot bot, java.util.function.Function<? super discord4j.core.object.entity.GuildChannel,java.lang.String> channelToString)
Reads the database value as a channel ID, attempts to convert it to a channel and gives a string representation of this channel.static DatabaseOutputFunction<java.lang.Long>
fromRoleId(Bot bot)
Reads the database value as a role ID, attempts to convert it to a role and gives a string representation of this role provided byDiscordFormatter.formatRole(Role)
.static DatabaseOutputFunction<java.lang.Long>
fromRoleId(Bot bot, java.util.function.Function<? super discord4j.core.object.entity.Role,java.lang.String> roleToString)
Reads the database value as a role ID, attempts to convert it to a role and gives a string representation of this role.static DatabaseOutputFunction<java.lang.Long>
fromUserId(Bot bot)
Reads the database value as a user ID, attempts to convert it to a user and gives a string representation of this user provided byDiscordFormatter.formatUser(User)
.static DatabaseOutputFunction<java.lang.Long>
fromUserId(Bot bot, java.util.function.Function<? super discord4j.core.object.entity.User,java.lang.String> userToString)
Reads the database value as a user ID, attempts to convert it to a user and gives a string representation of this user.static <D> DatabaseOutputFunction<D>
of(java.util.function.BiFunction<D,java.lang.Long,reactor.core.publisher.Mono<java.lang.String>> function)
Encapsulates a regular BiFunction into an instance ofDatabaseOutputFunction
.static <D> DatabaseOutputFunction<D>
stringValue()
Forwards the value from the database by returning its string representation provided byObject.toString()
-
Method Details
-
stringValue
Forwards the value from the database by returning its string representation provided byObject.toString()
- Type Parameters:
D
- the database type to convert from- Returns:
- a database output function
-
of
static <D> DatabaseOutputFunction<D> of(java.util.function.BiFunction<D,java.lang.Long,reactor.core.publisher.Mono<java.lang.String>> function)Encapsulates a regular BiFunction into an instance ofDatabaseOutputFunction
.- Type Parameters:
D
- the database type to convert from- Parameters:
function
- the function to encapsulate- Returns:
- a database output function wrapping the given function
-
from
static <D> DatabaseOutputFunction<D> from(java.util.function.Function<? super D,java.lang.String> converter)Forwards the value from the database by returning its string representation provided by the given function.- Type Parameters:
D
- the database type to convert from- Parameters:
converter
- the conversion function- Returns:
- a database output function providing a string representation for the value
-
fromRoleId
static DatabaseOutputFunction<java.lang.Long> fromRoleId(Bot bot, java.util.function.Function<? super discord4j.core.object.entity.Role,java.lang.String> roleToString)Reads the database value as a role ID, attempts to convert it to a role and gives a string representation of this role.- Parameters:
bot
- the bot instance to use in order to fetch rolesroleToString
- the function that provides the string representation for a role- Returns:
- a database output function giving a string representation for the role found.
-
fromRoleId
Reads the database value as a role ID, attempts to convert it to a role and gives a string representation of this role provided byDiscordFormatter.formatRole(Role)
.- Parameters:
bot
- the bot instance to use in order to fetch roles- Returns:
- a database output function giving a string representation for the role found.
-
fromUserId
static DatabaseOutputFunction<java.lang.Long> fromUserId(Bot bot, java.util.function.Function<? super discord4j.core.object.entity.User,java.lang.String> userToString)Reads the database value as a user ID, attempts to convert it to a user and gives a string representation of this user.- Parameters:
bot
- the bot instance to use in order to fetch usersuserToString
- the function that provides the string representation for a user- Returns:
- a database output function giving a string representation for the user found.
-
fromUserId
Reads the database value as a user ID, attempts to convert it to a user and gives a string representation of this user provided byDiscordFormatter.formatUser(User)
.- Parameters:
bot
- the bot instance to use in order to fetch users- Returns:
- a database output function giving a string representation for the user found.
-
fromChannelId
static DatabaseOutputFunction<java.lang.Long> fromChannelId(Bot bot, java.util.function.Function<? super discord4j.core.object.entity.GuildChannel,java.lang.String> channelToString)Reads the database value as a channel ID, attempts to convert it to a channel and gives a string representation of this channel.- Parameters:
bot
- the bot instance to use in order to fetch channelschannelToString
- the function that provides the string representation for a channel- Returns:
- a database output function giving a string representation for the channel found.
-
fromChannelId
Reads the database value as a channel ID, attempts to convert it to a channel and gives a string representation of this channel provided byDiscordFormatter.formatGuildChannel(GuildChannel)
.- Parameters:
bot
- the bot instance to use in order to fetch channels- Returns:
- a database output function giving a string representation for the channel found.
-