Package me.ahoo.cosid.converter
Class SnowflakeFriendlyIdConverter
java.lang.Object
me.ahoo.cosid.converter.SnowflakeFriendlyIdConverter
- All Implemented Interfaces:
IdConverter,Statistical
Converts Snowflake IDs to human-readable string format.
Provides friendly string representations of Snowflake IDs with embedded timestamp and machine information.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IdConverterShared instance using millisecond parser. -
Constructor Summary
ConstructorsConstructorDescriptionSnowflakeFriendlyIdConverter(SnowflakeIdStateParser snowflakeIdStateParser) Creates a converter with the specified parser. -
Method Summary
-
Field Details
-
INSTANCE
Shared instance using millisecond parser.
-
-
Constructor Details
-
SnowflakeFriendlyIdConverter
Creates a converter with the specified parser.- Parameters:
snowflakeIdStateParser- the Snowflake ID state parser
-
-
Method Details
-
getParser
Gets the parser.- Returns:
- the parser
-
asString
Description copied from interface:IdConverterConvert alongtype ID to itsStringrepresentation.This method transforms a numeric ID into a string format according to the specific conversion algorithm implemented by the converter. For example, a radix converter might convert the number 12345 to "3d7".
- Specified by:
asStringin interfaceIdConverter- Parameters:
id- Thelongtype ID to convert- Returns:
- The
Stringrepresentation of the ID
-
asLong
Description copied from interface:IdConverterConvert aStringtype ID back to itslongrepresentation.This method performs the reverse operation of
IdConverter.asString(long), transforming a string ID back into its original numeric form. Implementations should be able to correctly parse strings generated by theirIdConverter.asString(long)method.- Specified by:
asLongin interfaceIdConverter- Parameters:
idString- TheStringtype ID to convert- Returns:
- The
longrepresentation of the ID
-
stat
Description copied from interface:IdConverterGet statistical information about this converter.This method provides basic statistical information about the converter, including its implementation class name.
- Specified by:
statin interfaceIdConverter- Specified by:
statin interfaceStatistical- Returns:
- Statistical information about this converter
-