Class EntityUtil


  • public final class EntityUtil
    extends Object
    An utility class for entity processing.
    • Method Detail

      • getChannel

        public static Channel getChannel​(GatewayDiscordClient gateway,
                                         discord4j.discordjson.json.ChannelData data)
        An utility that converts some instance of ChannelData to its associated Channel type. That is to say, data.getType() == Channel#getType().getValue().
        Parameters:
        gateway - The GatewayDiscordClient associated to this object, must be non-null.
        data - The ChannelBean to convert.
        Returns:
        The converted Channel.
      • throwUnsupportedDiscordValue

        public static <T> T throwUnsupportedDiscordValue​(Object value)
        Throws an UnsupportedOperationException for an unknown Discord value. This method is intended to be used in enum value constructs such as Channel.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:
        true if the two objects are equal, false otherwise.
      • 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.