public final class SafeIdUtil
extends java.lang.Object
MiscUtil.parseSnowflake(String)
, a utility used in
several Object#getXById(String)
methods.
This class contains two static methods:
SafeIdUtil.safeConvert(String)
- Safely converts a String
to a format usable with MiscUtil.parseSnowflake(String)
.SafeIdUtil.checkId(String)
- Checks if a String is safe to use
with MiscUtil.parseSnowflake(String)
as it is.Modifier and Type | Method and Description |
---|---|
static boolean |
checkId(java.lang.String id)
Checks if the provided String ID is usable with
MiscUtil.parseSnowflake(String) . |
static long |
safeConvert(java.lang.String id)
Safely convert the provided String ID to a
long usable with
MiscUtil.parseSnowflake(String) . |
public static long safeConvert(java.lang.String id)
long
usable with
MiscUtil.parseSnowflake(String)
.id
- The String ID to be convertedlong
, then it will return the conversion.
0L
:
NumberFormatException
when used with
Long.parseLong(String)
.long
is negative.public static boolean checkId(java.lang.String id)
MiscUtil.parseSnowflake(String)
.id
- The String ID to be convertedtrue
if both of the following criteria are not met:
NumberFormatException
when used with
Long.parseLong(String)
.long
is negative.