@GwtIncompatible(value="java.util.Collections.shuffle, com.google.common.hash.Hasher, com.google.common.hash.Hashing")
public final class RandomNameGenerator
extends java.lang.Object
Unlike NameGenerator, names do not follow a predictable sequence such as a, b, ... z, aa, ab, ..., az, ba, ... but instead they are random, based on an external random seed. We do partially compromise for efficiency in that
More precisely:
This class is not thread safe.
Constructor and Description |
---|
RandomNameGenerator(java.util.Random random) |
Modifier and Type | Method and Description |
---|---|
com.google.javascript.jscomp.NameGenerator |
clone(java.util.Set<java.lang.String> reservedNames,
java.lang.String prefix,
char[] reservedCharacters)
Returns a clone of this NameGenerator, reconfigured and reset.
|
java.lang.String |
generateNextName()
Generates the next short name.
|
void |
reset(java.util.Set<java.lang.String> reservedNames,
java.lang.String prefix,
char[] reservedCharacters)
Reconfigures this NameGenerator, and resets it to the initial state.
|
void |
reset(java.util.Set<java.lang.String> reservedNames,
java.lang.String prefix,
char[] reservedFirstCharacters,
char[] reservedNonFirstCharacters)
Reconfigures this NameGenerator, and resets it to the initial state.
|
public void reset(java.util.Set<java.lang.String> reservedNames, java.lang.String prefix, @Nullable char[] reservedCharacters)
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 namespublic void reset(java.util.Set<java.lang.String> reservedNames, java.lang.String prefix, @Nullable char[] reservedFirstCharacters, @Nullable char[] reservedNonFirstCharacters)
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 namespublic com.google.javascript.jscomp.NameGenerator clone(java.util.Set<java.lang.String> reservedNames, java.lang.String prefix, @Nullable char[] reservedCharacters)
public java.lang.String generateNextName()
This generates names of increasing length. To minimize output size, therefore, it's good to call it for the most used symbols first.
Copyright © 2009-2020 Google. All Rights Reserved.