Package discord4j.core.util
Class EntityUtil
- java.lang.Object
-
- discord4j.core.util.EntityUtil
-
public final class EntityUtil extends Object
A utility class for entity processing.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DISCORD_EPOCH
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
equals(Entity entity, Object obj)
A utility that checks for equality between an entity and a generic object.static Channel
getChannel(GatewayDiscordClient gateway, discord4j.discordjson.json.ChannelData data)
static String
getEmojiString(ReactionEmoji emoji)
static int
hashCode(Entity entity)
A utility that gets the hash code of an entity.static <T> T
throwUnsupportedDiscordValue(Object value)
Deprecated.for removal in 3.3.0, no longer used
-
-
-
Field Detail
-
DISCORD_EPOCH
@Deprecated public static final long DISCORD_EPOCH
Deprecated.The UNIX time that represents Discord's epoch (January 1, 2015).- See Also:
- Constant Field Values
-
-
Method Detail
-
getEmojiString
public static String getEmojiString(ReactionEmoji emoji)
-
getChannel
public static Channel getChannel(GatewayDiscordClient gateway, discord4j.discordjson.json.ChannelData data)
A utility that converts some instance ofChannelData
to its associatedChannel
type
. That is to say,data.getType() == Channel#getType().getValue()
.- Parameters:
gateway
- TheGatewayDiscordClient
associated to this object, must be non-null.data
- TheChannelBean
to convert.- Returns:
- The converted
Channel
.
-
throwUnsupportedDiscordValue
@Deprecated public static <T> T throwUnsupportedDiscordValue(Object value)
Deprecated.for removal in 3.3.0, no longer usedThrows anUnsupportedOperationException
for an unknown Discord value. This method is intended to be used in enum value constructs such asChannel.Type.of(int)
when the value has not been properly supported.- Type Parameters:
T
- The return type. Used to simulate bottom type.- Parameters:
value
- The unknown Discord value.- Returns:
- Diverging function, never returns.
-
equals
public static boolean equals(Entity entity, @Nullable Object obj)
A utility that checks for equality between an entity and a generic object.- Parameters:
entity
- The entity to compare to.obj
- The object to compare to.- Returns:
true
if the two objects are equal,false
otherwise.
-
hashCode
public static int hashCode(Entity entity)
A utility that gets the hash code of an entity.- Parameters:
entity
- The entity to get a hash code from.- Returns:
- The hash code of the entity.
-
-