public final class OrderUtil extends Object
roles
and guild channels
.Modifier and Type | Field and Description |
---|---|
static Comparator<CategorizableChannel> |
BUCKETED_CHANNEL_ORDER
The ordering of
guild channels which considers channel type. |
static Comparator<GuildChannel> |
CHANNEL_ORDER
The base ordering of Discord
guild channels . |
static Comparator<Role> |
ROLE_ORDER
The ordering of Discord
roles . |
Constructor and Description |
---|
OrderUtil() |
Modifier and Type | Method and Description |
---|---|
static Flux<GuildChannel> |
orderGuildChannels(Flux<GuildChannel> channels)
Sorts
guild channels according to visual ordering in Discord. |
static Flux<Role> |
orderRoles(Flux<Role> roles)
Sorts
roles according to visual ordering in Discord. |
public static final Comparator<Role> ROLE_ORDER
public static final Comparator<GuildChannel> CHANNEL_ORDER
guild channels
.
In Discord, two orderable entities may have the same "raw position," the position as reported by the "position" field.
This conflict is resolved by comparing the creation time of the entities, reflected in their IDs
.
Note that this order is only applicable to channels if they are of the same type and in the same category. See
BUCKETED_CHANNEL_ORDER
for ordering between different channel types.
public static final Comparator<CategorizableChannel> BUCKETED_CHANNEL_ORDER
guild channels
which considers channel type.
Guild channels are first ordered by "bucket" which is determined by the type of the channels. Then,
CHANNEL_ORDER
is used to determine order within a buvket. Effectively, this only means that voice
channels always appear below other types of channels.
Note that this order is only applicable to channels if they are in the same category.
public static Flux<GuildChannel> orderGuildChannels(Flux<GuildChannel> channels)
guild channels
according to visual ordering in Discord. Channels at the top of the
list are first. This sorts channels within the same category according to BUCKETED_CHANNEL_ORDER
and
then sorts those categories according to CHANNEL_ORDER
.
This function can be used with Flux.transform(Function)
for better chaining:
guild.getChannels()
.transform(OrderUtil::orderGuildChannels)
channels
- The guild channels to sort.public static Flux<Role> orderRoles(Flux<Role> roles)
roles
according to visual ordering in Discord. Roles at the bottom of the list are first. This
sorts roles according to ROLE_ORDER
.
This function can be used with Flux.transform(Function)
for better chaining:
guild.getRoles()
.transform(OrderUtil::orderRoles)
roles
- The roles to sort.