Package me.ahoo.cosid.segment
Class StringSegmentId
java.lang.Object
me.ahoo.cosid.StringIdGeneratorDecorator
me.ahoo.cosid.segment.StringSegmentId
- All Implemented Interfaces:
AutoCloseable,Decorator<IdGenerator>,IdGenerator,IdGeneratorDecorator,SegmentId,Statistical,StringIdGenerator
String-based SegmentId wrapper.
Wraps a SegmentId with a string converter for generating string-based IDs while maintaining segment functionality.
-
Field Summary
Fields inherited from class me.ahoo.cosid.StringIdGeneratorDecorator
actual, idConverter -
Constructor Summary
ConstructorsConstructorDescriptionStringSegmentId(SegmentId actual, IdConverter idConverter) Creates a new StringSegmentId. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the decorated segment id when it isAutoCloseable, such as aSegmentChainId.current()Get the current ID segment being used for generation.@NonNull StringConverts with the group of the id when the converter uses it, so a grouped prefix comes from the segment the id came from.@NonNull GroupedIdGenerate an id together with the group of the segment it came from.stat()Get statistical information about this Segment ID generator.Methods inherited from class me.ahoo.cosid.StringIdGeneratorDecorator
getActual, idConverterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.IdGenerator
idConverterMethods inherited from interface me.ahoo.cosid.IdGeneratorDecorator
generateMethods inherited from interface me.ahoo.cosid.segment.SegmentId
generateGroupedAsString
-
Constructor Details
-
StringSegmentId
Creates a new StringSegmentId.- Parameters:
actual- the underlying segment IDidConverter- the converter for string generation
-
-
Method Details
-
close
Close the decorated segment id when it isAutoCloseable, such as aSegmentChainId.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- if closing it fails
-
generateAsString
Converts with the group of the id when the converter uses it, so a grouped prefix comes from the segment the id came from.- Specified by:
generateAsStringin interfaceIdGenerator- Specified by:
generateAsStringin interfaceStringIdGenerator- Returns:
- A unique distributed ID as a string value
-
current
Description copied from interface:SegmentIdGet the current ID segment being used for generation.This method returns the segment from which IDs are currently being allocated. The segment contains the range of available IDs and tracks the current position within that range.
-
generateGrouped
Description copied from interface:SegmentIdGenerate an id together with the group of the segment it came from.- Specified by:
generateGroupedin interfaceSegmentId- Returns:
- the id and its group,
GroupedKey.NEVERwhen it is not grouped
-
stat
Description copied from interface:SegmentIdGet statistical information about this Segment ID generator.This method provides detailed information about the generator's current state, including segment metadata and availability status.
- Specified by:
statin interfaceIdGenerator- Specified by:
statin interfaceIdGeneratorDecorator- Specified by:
statin interfaceSegmentId- Specified by:
statin interfaceStatistical- Specified by:
statin interfaceStringIdGenerator- Returns:
- Statistical information about this Segment ID generator
-