Class NameGenerator
java.lang.Object
com.github.yellowstonegames.text.NameGenerator
Based on work by Nolithius available at the following two sites:
GitHub for weighted-letter-namegen
Google Code for weighted-letter-namegen
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNameGenerator(String[] names) Creates the generator by seeding the provided list of names.NameGenerator(String[] names, int consonantLimit) Creates the generator by seeding the provided list of names.NameGenerator(String[] names, int consonantLimit, com.github.tommyettinger.random.EnhancedRandom rng) Creates the generator by seeding the provided list of names. -
Method Summary
Modifier and TypeMethodDescriptiongenerate()Gets one random String name.String[]generate(int amountToGenerate) Gets an array of random String names, sized to match amountToGenerate.generateList(int amountToGenerate) Gets an ArrayList of random String names, sized to match amountToGenerate.
-
Field Details
-
VIKING_STYLE_NAMES
-
STAR_WARS_STYLE_NAMES
-
COMMON_USA_MALE_NAMES
-
COMMON_USA_FEMALE_NAMES
-
COMMON_USA_LAST_NAMES
-
LOVECRAFT_MYTHOS_NAMES
-
-
Constructor Details
-
NameGenerator
Creates the generator by seeding the provided list of names.- Parameters:
names- an array of Strings that are typical names to be emulated
-
NameGenerator
Creates the generator by seeding the provided list of names.- Parameters:
names- an array of Strings that are typical names to be emulatedconsonantLimit- the maximum allowed consonants in a row
-
NameGenerator
public NameGenerator(String[] names, int consonantLimit, com.github.tommyettinger.random.EnhancedRandom rng) Creates the generator by seeding the provided list of names. The given RNG will be used for all random decisions this has to make, so if it has the same state (and RandomnessSource) on different runs through the program, it will produce the same names reliably.- Parameters:
names- an array of Strings that are typical names to be emulatedconsonantLimit- the maximum allowed consonants in a rowrng- the source of randomness to be used
-
-
Method Details
-
generate
-
generateList
-
generate
Gets an array of random String names, sized to match amountToGenerate.- Parameters:
amountToGenerate- how many String items to include in the returned array- Returns:
- an array of random String names
-