Class Faker


  • public class Faker
    extends java.lang.Object
    Provides utility methods for generating fake strings, such as names, phone numbers, addresses. generate random strings with given patterns
    Author:
    ren
    • Constructor Detail

      • Faker

        public Faker()
      • Faker

        public Faker​(java.util.Locale locale)
      • Faker

        public Faker​(java.util.Random random)
      • Faker

        public Faker​(java.util.Locale locale,
                     java.util.Random random)
      • Faker

        public Faker​(java.util.Locale locale,
                     RandomService randomService)
    • Method Detail

      • instance

        public static Faker instance()
        Constructs Faker instance with default argument.
        Returns:
        Faker()
      • instance

        public static Faker instance​(java.util.Locale locale)
        Constructs Faker instance with provided Locale.
        Parameters:
        locale - - Locale
        Returns:
        Faker(Locale)
      • instance

        public static Faker instance​(java.util.Random random)
        Constructs Faker instance with provided Random.
        Parameters:
        random - - Random
        Returns:
        Faker(Random)
      • instance

        public static Faker instance​(java.util.Locale locale,
                                     java.util.Random random)
        Constructs Faker instance with provided Locale and Random.
        Parameters:
        locale - - Locale
        random - - Random
        Returns:
        Faker(Locale, Random)
      • numerify

        public java.lang.String numerify​(java.lang.String numberString)
        Returns a string with the '#' characters in the parameter replaced with random digits between 0-9 inclusive.

        For example, the string "ABC##EFG" could be replaced with a string like "ABC99EFG".

        Parameters:
        numberString -
        Returns:
      • letterify

        public java.lang.String letterify​(java.lang.String letterString)
        Returns a string with the '?' characters in the parameter replaced with random alphabetic characters.

        For example, the string "12??34" could be replaced with a string like "12AB34".

        Parameters:
        letterString -
        Returns:
      • letterify

        public java.lang.String letterify​(java.lang.String letterString,
                                          boolean isUpper)
        Returns a string with the '?' characters in the parameter replaced with random alphabetic characters.

        For example, the string "12??34" could be replaced with a string like "12AB34".

        Parameters:
        letterString -
        isUpper -
        Returns:
      • bothify

        public java.lang.String bothify​(java.lang.String string)
        Applies both a numerify(String) and a letterify(String) over the incoming string.
        Parameters:
        string -
        Returns:
      • bothify

        public java.lang.String bothify​(java.lang.String string,
                                        boolean isUpper)
        Applies both a numerify(String) and a letterify(String) over the incoming string.
        Parameters:
        string -
        isUpper -
        Returns:
      • regexify

        public java.lang.String regexify​(java.lang.String regex)
        Generates a String that matches the given regular expression.
      • ancient

        public Ancient ancient()
      • app

        public App app()
      • artist

        public Artist artist()
      • avatar

        public Avatar avatar()
      • music

        public Music music()
      • name

        public Name name()
      • number

        public Number number()
      • pokemon

        public Pokemon pokemon()
      • lorem

        public Lorem lorem()
      • address

        public Address address()
      • book

        public Book book()
      • buffy

        public Buffy buffy()
      • color

        public Color color()
      • company

        public Company company()
      • crypto

        public Crypto crypto()
      • hacker

        public Hacker hacker()
      • options

        public Options options()
      • code

        public Code code()
      • file

        public File file()
      • finance

        public Finance finance()
      • food

        public Food food()
      • dog

        public Dog dog()
      • space

        public Space space()
      • bool

        public Bool bool()
      • team

        public Team team()
      • beer

        public Beer beer()
      • cat

        public Cat cat()
      • stock

        public Stock stock()
      • zelda

        public Zelda zelda()
      • esports

        public Esports esports()
      • friends

        public Friends friends()
      • hipster

        public Hipster hipster()
      • job

        public Job job()
      • yoda

        public Yoda yoda()
      • matz

        public Matz matz()
      • witcher

        public Witcher witcher()
      • hobbit

        public Hobbit hobbit()
      • robin

        public Robin robin()
      • weather

        public Weather weather()
      • medical

        public Medical medical()
      • country

        public Country country()
      • animal

        public Animal animal()
      • nation

        public Nation nation()
      • dune

        public Dune dune()
      • resolve

        public java.lang.String resolve​(java.lang.String key)
      • expression

        public java.lang.String expression​(java.lang.String expression)
        Allows the evaluation of native YML expressions to allow you to build your own.

        The following are valid expressions:

        • #{regexify '(a|b){2,3}'}
        • #{regexify '\\.\\*\\?\\+'}
        • #{bothify '????','false'}
        • #{Name.first_name} #{Name.first_name} #{Name.last_name}
        • #{number.number_between '1','10'}
        Parameters:
        expression - (see examples above)
        Returns:
        the evaluated string expression
        Throws:
        java.lang.RuntimeException - if unable to evaluate the expression