Package me.ahoo.cosid.converter
Class GroupedPrefixIdConverter
java.lang.Object
me.ahoo.cosid.converter.GroupedPrefixIdConverter
- All Implemented Interfaces:
Decorator<IdConverter>,IdConverter,Statistical
Converter that prepends a dynamic group key as prefix to string IDs.
The group key comes with the id: asString(long, GroupedKey), as called by
SegmentId.generateGroupedAsString() and the string segment generators.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGroupedPrefixIdConverter(String delimiter, IdConverter actual) Creates a grouped prefix converter. -
Method Summary
Modifier and TypeMethodDescriptionlongConvert aStringtype ID back to itslongrepresentation.@NonNull StringasString(long id) Not supported: the group is not known from the id alone.@NonNull StringasString(long id, @NonNull GroupedKey group) Prefix the id with the key ofgroup.@NonNull IdConverterGet the actual (wrapped) object that this decorator is enhancing.Gets the delimiter.stat()Get statistical information about this converter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.IdConverter
asString
-
Field Details
-
DEFAULT_DELIMITER
Default delimiter between group key and ID.- See Also:
-
-
Constructor Details
-
GroupedPrefixIdConverter
Creates a grouped prefix converter.- Parameters:
delimiter- the delimiter between group key and IDactual- the underlying converter
-
-
Method Details
-
getActual
Description copied from interface:DecoratorGet the actual (wrapped) object that this decorator is enhancing.This method returns the underlying object that this decorator is wrapping. For ID generators, this would typically be the base generator that is being enhanced with additional functionality.
- Specified by:
getActualin interfaceDecorator<IdConverter>- Returns:
- The actual object being decorated
-
getDelimiter
Gets the delimiter.- Returns:
- the delimiter
-
asString
Not supported: the group is not known from the id alone.- Specified by:
asStringin interfaceIdConverter- Parameters:
id- Thelongtype ID to convert- Returns:
- The
Stringrepresentation of the ID - Throws:
UnsupportedOperationException- always; useasString(long, GroupedKey)
-
asString
Prefix the id with the key ofgroup.- Specified by:
asStringin interfaceIdConverter- Parameters:
id- the idgroup- the group of the segment the id came from,GroupedKey.NEVERwhen it is not grouped- 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
-