Class LocalePicker

java.lang.Object
net.datafaker.service.LocalePicker

public class LocalePicker extends Object
  • Constructor Details

    • LocalePicker

      public LocalePicker()
      Constructor for LocalePicker class
    • LocalePicker

      public LocalePicker(Random random)
      Constructor for LocalePicker class
      Parameters:
      random - random number generator (can utilize seed for deterministic random selection)
  • Method Details

    • getAllSupportedLocales

      public List<String> getAllSupportedLocales()
      Retrieves list of all locales supported by Datafaker
      Returns:
      a List of Strings with the name of the locale (eg. "es", "es-MX")
    • getLocaleString

      public String getLocaleString(Random random)
      Select a locale at random with replacement
      Parameters:
      random - random number generator (can utilize seed for deterministic random selection)
      Returns:
      String of a randomly selected locale (eg. "es", "es-MX")
    • getLocaleStringWithoutReplacement

      public String getLocaleStringWithoutReplacement(Random random)
      Select a locale at random without replacement. This can be used to rotate through all supported locales
      Parameters:
      random - random number generator (can utilize seed for deterministic random selection)
      Returns:
      String of a randomly selected locale (eg. "es", "es-MX")
    • getLocale

      public Locale getLocale()
      Returns:
      Locale object of a randomly selected locale (eg. "es", "es-MX"). Locale is selected at random WITH replacement from all supported locales
    • getLocaleWithoutReplacement

      public Locale getLocaleWithoutReplacement()
      Returns:
      Locale object of a randomly selected locale (eg. "es", "es-MX"). Locale is selected at random WITHOUT replacement from all supported locales