Class NameGenerator

java.lang.Object
com.github.yellowstonegames.text.NameGenerator

public class NameGenerator extends Object
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 Details

    • VIKING_STYLE_NAMES

      public static final String[] VIKING_STYLE_NAMES
    • STAR_WARS_STYLE_NAMES

      public static final String[] STAR_WARS_STYLE_NAMES
    • COMMON_USA_MALE_NAMES

      public static final String[] COMMON_USA_MALE_NAMES
    • COMMON_USA_FEMALE_NAMES

      public static final String[] COMMON_USA_FEMALE_NAMES
    • COMMON_USA_LAST_NAMES

      public static final String[] COMMON_USA_LAST_NAMES
    • LOVECRAFT_MYTHOS_NAMES

      public static final String[] LOVECRAFT_MYTHOS_NAMES
  • Constructor Details

    • NameGenerator

      public NameGenerator(String[] names)
      Creates the generator by seeding the provided list of names.
      Parameters:
      names - an array of Strings that are typical names to be emulated
    • NameGenerator

      public NameGenerator(String[] names, int consonantLimit)
      Creates the generator by seeding the provided list of names.
      Parameters:
      names - an array of Strings that are typical names to be emulated
      consonantLimit - 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 emulated
      consonantLimit - the maximum allowed consonants in a row
      rng - the source of randomness to be used
  • Method Details

    • generate

      public String generate()
      Gets one random String name.
      Returns:
      a single random String name
    • generateList

      public ArrayList<String> generateList(int amountToGenerate)
      Gets an ArrayList of random String names, sized to match amountToGenerate.
      Parameters:
      amountToGenerate - how many String items to include in the returned ArrayList
      Returns:
      an ArrayList of random String names
    • generate

      public String[] generate(int amountToGenerate)
      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