public final class Snowflake extends Object implements Comparable<Snowflake>
| Modifier and Type | Field and Description |
|---|---|
static long |
DISCORD_EPOCH
The UNIX time that represents Discord's epoch (January 1, 2015).
|
| Modifier and Type | Method and Description |
|---|---|
BigInteger |
asBigInteger()
Gets the unsigned ID of this
Snowflake as a BigInteger. |
long |
asLong()
Gets the unsigned ID of this
Snowflake as a primitive long. |
static long |
asLong(String id)
Constructs a
Snowflake represented as a long utilizing an unsigned ID. |
String |
asString()
Gets the unsigned ID of this
Snowflake as an object String. |
static String |
asString(long id)
Constructs a
Snowflake represented as a String utilizing an unsigned ID. |
int |
compareTo(Snowflake other)
Compares this snowflake to the specified snowflake.
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this
Snowflake. |
Instant |
getTimestamp()
Gets the timestamp of this
Snowflake. |
int |
hashCode()
Gets the hash code value of the
ID. |
static Snowflake |
of(BigInteger id)
Constructs a
Snowflake utilizing a BigInteger representing an unsigned ID. |
static Snowflake |
of(Instant timestamp)
Constructs a
Snowflake utilizing a timestamp. |
static Snowflake |
of(long id)
Constructs a
Snowflake utilizing an unsigned ID. |
static Snowflake |
of(String id)
Constructs a
Snowflake utilizing an unsigned ID. |
String |
toString()
Gets the String representation of this
Snowflake. |
public static final long DISCORD_EPOCH
public static Snowflake of(long id)
Snowflake utilizing an unsigned ID.id - The unsigned ID to construct a Snowflake.Snowflake with the unsigned ID.public static Snowflake of(String id)
Snowflake utilizing an unsigned ID.id - The unsigned ID to construct a Snowflake. Must be non-null.Snowflake with the unsigned ID.NumberFormatException - If id is not an unsigned ID.public static Snowflake of(Instant timestamp)
Snowflake utilizing a timestamp. The constructed Snowflake is only guaranteed to
contain accurate information about its timestamp; the other portions are undefined.timestamp - The timestamp to construct a Snowflake. Must be non-null.Snowflake with the timestamp.public static Snowflake of(BigInteger id)
Snowflake utilizing a BigInteger representing an unsigned ID.id - The BigInteger representing an unsigned ID to construct a Snowflake. Must be non-null.Snowflake with an unsigned ID.public static long asLong(String id)
Snowflake represented as a long utilizing an unsigned ID.id - The unsigned ID to construct a Snowflake. Must be non-null.Snowflake with the unsigned ID.NumberFormatException - If id is not an unsigned ID.public static String asString(long id)
Snowflake represented as a String utilizing an unsigned ID.id - The unsigned ID to construct a Snowflake. Must be non-null.Snowflake with the unsigned ID.NumberFormatException - If id is not an unsigned ID.public long asLong()
Snowflake as a primitive long.Snowflake as a primitive long.public String asString()
Snowflake as an object String.Snowflake as an object String.public Instant getTimestamp()
Snowflake.Snowflake.public BigInteger asBigInteger()
Snowflake as a BigInteger.Snowflake as a BigInteger.public int compareTo(Snowflake other)
The comparison is based on the timestamp portion of the snowflakes.
compareTo in interface Comparable<Snowflake>other - The other snowflake to compare to.public boolean equals(@Nullable Object obj)
Snowflake.
The other object is considered equal if:
Snowflake and;IDs.public int hashCode()
ID.public String toString()
Snowflake.
The format returned by this method is unspecified and may vary between implementations; however, it is guaranteed
to always be non-empty. This method is not suitable for obtaining the ID; use asString() instead.
toString in class ObjectSnowflake.asString()