Class ExTermEncoder

java.lang.Object
net.dv8tion.jda.api.utils.data.etf.ExTermEncoder

public class ExTermEncoder extends Object
Encodes an object into a binary ETF representation.
Since:
4.2.1
See Also:
  • Constructor Details

    • ExTermEncoder

      public ExTermEncoder()
  • Method Details

    • pack

      @Nonnull public static ByteBuffer pack(Object data)
      Encodes the provided object into an ETF buffer.

      The mapping is as follows:

      • String -> Binary
      • Map -> Map
      • Collection -> List | NIL
      • Byte -> Small Int
      • Integer, Short -> Int | Small Int
      • Long -> Small BigInt | Int | Small Int
      • Float, Double -> New Float
      • Boolean -> Atom(Boolean)
      • null -> Atom("nil")
      Parameters:
      data - The object to encode
      Returns:
      ByteBuffer with the encoded ETF term
      Throws:
      UnsupportedOperationException - If there is no type mapping for the provided object