Package com.globalmentor.lex
Class AbstractDelimiterCompoundTokenization
java.lang.Object
com.globalmentor.lex.AbstractDelimiterCompoundTokenization
- All Implemented Interfaces:
CompoundTokenization
,Named<String>
public abstract class AbstractDelimiterCompoundTokenization
extends Object
implements CompoundTokenization
A base compound tokenization strategy that relies on a delimiter between components.
- Author:
- Garret Wilson
-
Field Summary
Fields inherited from interface com.globalmentor.lex.CompoundTokenization
CAMEL_CASE, KEBAB_CASE, KEBAB_CASE_DELIMITER, SNAKE_CASE, SNAKE_CASE_DELIMITER
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractDelimiterCompoundTokenization
(char delimiter) Delimiters constructor. -
Method Summary
Modifier and TypeMethodDescriptionchar
join
(Iterable<? extends CharSequence> components) Joins components into a compound token.split
(CharSequence token) Splits a compound token into its component parts.toKebabCase
(CharSequence token) Converts a token from one tokenization tokebab-case
.toSnakeCase
(CharSequence token) Converts a token from one tokenization tosnake_case
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.globalmentor.lex.CompoundTokenization
toCamelCase
-
Constructor Details
-
AbstractDelimiterCompoundTokenization
public AbstractDelimiterCompoundTokenization(char delimiter) Delimiters constructor.- Parameters:
delimiter
- The delimiter for splitting and joining a component token.
-
-
Method Details
-
getDelimiter
public char getDelimiter()- Returns:
- The delimiter used by this tokenization.
-
split
Description copied from interface:CompoundTokenization
Splits a compound token into its component parts.- Specified by:
split
in interfaceCompoundTokenization
- Parameters:
token
- The compound token to split.- Returns:
- The components of the compound token.
-
join
Joins components into a compound token.- Specified by:
join
in interfaceCompoundTokenization
- Implementation Note:
- This implementation performs joining manually rather than calling
String.join(CharSequence, Iterable)
for efficiency and to check each component. - Parameters:
components
- The components to join.- Returns:
- The compound token resulting from joining the given components.
- Throws:
IllegalArgumentException
- if one of the components already contains the tokenization delimiter.
-
toKebabCase
Converts a token from one tokenization tokebab-case
.- Specified by:
toKebabCase
in interfaceCompoundTokenization
- Implementation Specification:
- This implementation does a simple delimiter replacement, which is more efficient than splitting and joining.
- Parameters:
token
- The compound token.- Returns:
- The same compound token using the
kebab-case
tokenization. - See Also:
-
toSnakeCase
Converts a token from one tokenization tosnake_case
.- Specified by:
toSnakeCase
in interfaceCompoundTokenization
- Implementation Specification:
- This implementation does a simple delimiter replacement, which is more efficient than splitting and joining.
- Parameters:
token
- The compound token.- Returns:
- The same compound token using the
snake_case
tokenization. - See Also:
-