Package me.ahoo.cosid.snowflake
Class SnowflakeIdStateParser
java.lang.Object
me.ahoo.cosid.snowflake.SnowflakeIdStateParser
- Direct Known Subclasses:
MillisecondSnowflakeIdStateParser
,SecondSnowflakeIdStateParser
SnowflakeId State Parser.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSnowflakeIdStateParser
(long epoch, int timestampBit, int machineBit, int sequenceBit) SnowflakeIdStateParser
(long epoch, int timestampBit, int machineBit, int sequenceBit, ZoneId zoneId, boolean padStart) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DateTimeFormatter
protected abstract long
getDiffTime
(LocalDateTime timestamp) int
int
protected abstract LocalDateTime
getTimestamp
(long diffTime) boolean
static SnowflakeIdStateParser
of
(SnowflakeId snowflakeId) static SnowflakeIdStateParser
of
(SnowflakeId snowflakeId, ZoneId zoneId, boolean padStart) parse
(long id) int
parseMachineId
(long id) long
parseSequence
(long id) parseTimestamp
(long id)
-
Field Details
-
DELIMITER
- See Also:
-
zoneId
-
epoch
protected final long epoch -
sequenceBit
protected final int sequenceBit -
sequenceMask
protected final long sequenceMask -
machineBit
protected final int machineBit -
machineMask
protected final long machineMask -
machineLeft
protected final int machineLeft -
timestampBit
protected final int timestampBit -
timestampMask
protected final long timestampMask -
timestampLeft
protected final int timestampLeft -
padStart
protected final boolean padStart
-
-
Constructor Details
-
SnowflakeIdStateParser
public SnowflakeIdStateParser(long epoch, int timestampBit, int machineBit, int sequenceBit) -
SnowflakeIdStateParser
public SnowflakeIdStateParser(long epoch, int timestampBit, int machineBit, int sequenceBit, ZoneId zoneId, boolean padStart)
-
-
Method Details
-
getZoneId
-
isPadStart
public boolean isPadStart() -
getMachineCharSize
public int getMachineCharSize() -
getSequenceCharSize
public int getSequenceCharSize() -
getDateTimeFormatter
-
getTimestamp
-
getDiffTime
-
parse
-
parse
-
parseTimestamp
-
parseMachineId
public int parseMachineId(long id) -
parseSequence
public long parseSequence(long id) -
of
-
of
-