Interface DatabaseOutputFunction<D>

  • All Superinterfaces:
    BiFunction<D,​Long,​reactor.core.publisher.Mono<String>>

    public interface DatabaseOutputFunction<D>
    extends BiFunction<D,​Long,​reactor.core.publisher.Mono<String>>
    Function that determines the string to display to the user after reading the value from teh database.
    • Method Detail

      • stringValue

        static <D> DatabaseOutputFunction<D> stringValue()
        Forwards the value from the database by returning its string representation provided by Object.toString()
        Type Parameters:
        D - the database type to convert from
        Returns:
        a database output function
      • of

        static <D> DatabaseOutputFunction<D> of​(BiFunction<D,​Long,​reactor.core.publisher.Mono<String>> function)
        Encapsulates a regular BiFunction into an instance of DatabaseOutputFunction.
        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​(Function<? super D,​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<Long> fromRoleId​(Bot bot,
                                                       Function<? super discord4j.core.object.entity.Role,​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 roles
        roleToString - the function that provides the string representation for a role
        Returns:
        a database output function giving a string representation for the role found.
      • fromRoleId

        static DatabaseOutputFunction<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 by DiscordFormatter.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<Long> fromUserId​(Bot bot,
                                                       Function<? super discord4j.core.object.entity.User,​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 users
        userToString - the function that provides the string representation for a user
        Returns:
        a database output function giving a string representation for the user found.
      • fromUserId

        static DatabaseOutputFunction<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 by User.getTag().
        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<Long> fromChannelId​(Bot bot,
                                                          Function<? super discord4j.core.object.entity.channel.GuildChannel,​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 channels
        channelToString - the function that provides the string representation for a channel
        Returns:
        a database output function giving a string representation for the channel found.
      • fromChannelId

        static DatabaseOutputFunction<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 by DiscordFormatter.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.