Package discord4j.core.util
Class EntityUtil
- java.lang.Object
-
- discord4j.core.util.EntityUtil
-
public final class EntityUtil extends Object
An utility class for entity processing.
-
-
Field Summary
Fields Modifier and Type Field Description static longDISCORD_EPOCHDeprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanequals(Entity entity, Object obj)An utility that checks for equality between an entity and a generic object.static ChannelgetChannel(GatewayDiscordClient gateway, discord4j.discordjson.json.ChannelData data)static StringgetEmojiString(ReactionEmoji emoji)static inthashCode(Entity entity)An utility that gets the hash code of an entity.static <T> TthrowUnsupportedDiscordValue(Object value)Throws anUnsupportedOperationExceptionfor an unknown Discord value.
-
-
-
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)
An utility that converts some instance ofChannelDatato its associatedChanneltype. That is to say,data.getType() == Channel#getType().getValue().- Parameters:
gateway- TheGatewayDiscordClientassociated to this object, must be non-null.data- TheChannelBeanto convert.- Returns:
- The converted
Channel.
-
throwUnsupportedDiscordValue
public static <T> T throwUnsupportedDiscordValue(Object value)
Throws anUnsupportedOperationExceptionfor 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)
An 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:
trueif the two objects are equal,falseotherwise.
-
hashCode
public static int hashCode(Entity entity)
An 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.
-
-