Interface IdConverter
- All Superinterfaces:
Statistical
- All Known Implementing Classes:
DatePrefixIdConverter,GroupedPrefixIdConverter,PrefixIdConverter,Radix36IdConverter,Radix62IdConverter,RadixIdConverter,SnowflakeFriendlyIdConverter,SuffixIdConverter,ToStringIdConverter
This interface defines the contract for converting distributed IDs between
their numeric (long) and string representations. This is useful when
you need to store IDs as strings in databases or URLs but work with them as
numbers in application logic.
Common implementations include:
Radix62IdConverter- Converts to radix-62 stringsRadix36IdConverter- Converts to radix-36 stringsToStringIdConverter- Simple string conversion
Implementations of this interface are expected to be thread-safe and can be used concurrently across multiple threads.
-
Method Summary
-
Method Details
-
asString
Convert 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".
- Parameters:
id- Thelongtype ID to convert- Returns:
- The
Stringrepresentation of the ID
-
asLong
Convert aStringtype ID back to itslongrepresentation.This method performs the reverse operation of
asString(long), transforming a string ID back into its original numeric form. Implementations should be able to correctly parse strings generated by theirasString(long)method.- Parameters:
idString- TheStringtype ID to convert- Returns:
- The
longrepresentation of the ID
-
stat
Get statistical information about this converter.This method provides basic statistical information about the converter, including its implementation class name.
- Specified by:
statin interfaceStatistical- Returns:
- Statistical information about this converter
-