Enum Class Alphabet
- All Implemented Interfaces:
Serializable, Comparable<Alphabet>, Constable
Predefined Alphabets for NanoID
NanoID预定义字母表
Provides commonly used character sets for NanoID generation.
提供常用的NanoID生成字符集。
Available Alphabets | 可用字母表:
- DEFAULT - URL-safe (64 chars) | URL安全(64字符)
- ALPHANUMERIC - Letters and digits | 字母和数字
- ALPHABETIC - Letters only | 仅字母
- NUMERIC - Digits only | 仅数字
- HEX_LOWERCASE/UPPERCASE - Hexadecimal | 十六进制
- NOLOOK_ALIKE - No ambiguous chars | 无歧义字符
Usage Examples | 使用示例:
NanoIdGenerator gen = NanoIdGenerator.builder()
.alphabet(Alphabet.ALPHANUMERIC)
.size(16)
.build();
String chars = Alphabet.DEFAULT.getChars();
int size = Alphabet.NUMERIC.size();
Features | 主要功能:
- Predefined character sets for NanoID generation - NanoID生成的预定义字符集
- URL-safe, numeric, alphanumeric alphabets - URL安全、数字、字母数字字符集
- Custom alphabet validation - 自定义字符集验证
Security | 安全性:
- Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-id V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAlphabetic only 仅字母Alphanumeric alphabet 字母数字字母表Default URL-safe alphabet 默认URL安全字母表Hexadecimal lowercase 十六进制小写Hexadecimal uppercase 十六进制大写No look-alike characters 无歧义字符Numeric only 仅数字 -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) Gets a character at index 获取指定索引的字符getChars()Gets the character set 获取字符集intsize()Gets the size of the alphabet 获取字母表大小static AlphabetReturns the enum constant of this class with the specified name.static Alphabet[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DEFAULT
Default URL-safe alphabet 默认URL安全字母表Contains: A-Z, a-z, 0-9, _, -
-
ALPHANUMERIC
Alphanumeric alphabet 字母数字字母表Contains: A-Z, a-z, 0-9
-
ALPHABETIC
Alphabetic only 仅字母Contains: A-Z, a-z
-
NUMERIC
Numeric only 仅数字Contains: 0-9
-
HEX_LOWERCASE
Hexadecimal lowercase 十六进制小写Contains: 0-9, a-f
-
HEX_UPPERCASE
Hexadecimal uppercase 十六进制大写Contains: 0-9, A-F
-
NOLOOK_ALIKE
No look-alike characters 无歧义字符Excludes: 0, O, 1, l, I to avoid confusion
排除:0, O, 1, l, I 以避免混淆
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getChars
-
size
public int size()Gets the size of the alphabet 获取字母表大小- Returns:
- number of characters | 字符数量
-
charAt
public char charAt(int index) Gets a character at index 获取指定索引的字符- Parameters:
index- the index | 索引- Returns:
- character at index | 索引处的字符
-