Package com.google.javascript.jscomp
Interface NameGenerator
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
DefaultNameGenerator
,RandomNameGenerator
A class that generates unique JavaScript variable/property names.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a clone of this NameGenerator, reconfigured and reset.Generates the next name.void
Reconfigures this NameGenerator, and resets it to the initial state.void
reset
(Set<String> reservedNames, String prefix, char @Nullable [] reservedFirstCharacters, char @Nullable [] reservedNonFirstCharacters) Reconfigures this NameGenerator, and resets it to the initial state.
-
Method Details
-
reset
Reconfigures this NameGenerator, and resets it to the initial state.- Parameters:
reservedNames
- set of names that are reserved; generated names will not include these names. This set is referenced rather than copied, so changes to the set will be reflected in how names are generated.prefix
- all generated names begin with this prefix.reservedCharacters
- If specified these characters won't be used in generated names
-
reset
void reset(Set<String> reservedNames, String prefix, char @Nullable [] reservedFirstCharacters, char @Nullable [] reservedNonFirstCharacters) Reconfigures this NameGenerator, and resets it to the initial state.- Parameters:
reservedNames
- set of names that are reserved; generated names will not include these names. This set is referenced rather than copied, so changes to the set will be reflected in how names are generated.prefix
- all generated names begin with this prefix.reservedFirstCharacters
- If specified these characters won't be used as the first character in generated namesreservedNonFirstCharacters
- If specified these characters won't be used for characters (after the first) in generated names
-
clone
Returns a clone of this NameGenerator, reconfigured and reset. -
generateNextName
String generateNextName()Generates the next name.
-