Class Id

java.lang.Object
discord4j.discordjson.Id

public class Id extends Object
Represents an unsigned 64-bit ID. This object is serialized through String despite using long field for storage and is used when building immutable objects for an alternative compact structure, reducing required memory.
  • Method Details

    • of

      public static Id of(long value)
      Constructs an ID utilizing an unsigned ID.
      Parameters:
      value - The unsigned ID to construct a ID.
      Returns:
      A constructed ID with the unsigned ID.
    • of

      public static Id of(String value)
      Constructs an ID utilizing an unsigned ID.
      Parameters:
      value - The unsigned ID to construct a ID. Must be non-null.
      Returns:
      A constructed ID with the unsigned ID.
      Throws:
      NumberFormatException - If id is not an unsigned ID.
    • asString

      public String asString()
      Gets the unsigned ID as an object String.
      Returns:
      The unsigned ID as String.
    • asLong

      public long asLong()
      Gets the unsigned ID as a primitive long.
      Returns:
      The unsigned ID as long.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object