Package com.github.javafaker
Class Faker
- java.lang.Object
-
- com.github.javafaker.Faker
-
public class Faker extends java.lang.ObjectProvides utility methods for generating fake strings, such as names, phone numbers, addresses. generate random strings with given patterns- Author:
- ren
-
-
Constructor Summary
Constructors Constructor Description Faker()Faker(FakeValuesService fakeValuesService, RandomService random)Faker(java.util.Locale locale)Faker(java.util.Locale locale, RandomService randomService)Faker(java.util.Locale locale, java.util.Random random)Faker(java.util.Random random)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Addressaddress()Ancientancient()Animalanimal()Appapp()AquaTeenHungerForceaquaTeenHungerForce()Artistartist()Avataravatar()Aviationaviation()BackToTheFuturebackToTheFuture()Beerbeer()Bookbook()Boolbool()java.lang.Stringbothify(java.lang.String string)Applies both anumerify(String)and aletterify(String)over the incoming string.java.lang.Stringbothify(java.lang.String string, boolean isUpper)Applies both anumerify(String)and aletterify(String)over the incoming string.Buffybuffy()Businessbusiness()Catcat()ChuckNorrischuckNorris()Codecode()Colorcolor()Commercecommerce()Companycompany()Countrycountry()Cryptocrypto()Currencycurrency()DateAndTimedate()Demographicdemographic()Dogdog()DragonBalldragonBall()Dunedune()Educatoreducator()ElderScrollselderScrolls()Esportsesports()java.lang.Stringexpression(java.lang.String expression)Allows the evaluation of native YML expressions to allow you to build your own.Filefile()Financefinance()Foodfood()Friendsfriends()FunnyNamefunnyName()GameOfThronesgameOfThrones()Hackerhacker()HarryPotterharryPotter()Hipsterhipster()HitchhikersGuideToTheGalaxyhitchhikersGuideToTheGalaxy()Hobbithobbit()HowIMetYourMotherhowIMetYourMother()IdNumberidNumber()static Fakerinstance()Constructs Faker instance with default argument.static Fakerinstance(java.util.Locale locale)Constructs Faker instance with providedLocale.static Fakerinstance(java.util.Locale locale, java.util.Random random)Constructs Faker instance with providedLocaleandRandom.static Fakerinstance(java.util.Random random)Constructs Faker instance with providedRandom.Internetinternet()Jobjob()LeagueOfLegendsleagueOfLegends()Lebowskilebowski()java.lang.Stringletterify(java.lang.String letterString)Returns a string with the '?' characters in the parameter replaced with random alphabetic characters.java.lang.Stringletterify(java.lang.String letterString, boolean isUpper)Returns a string with the '?' characters in the parameter replaced with random alphabetic characters.LordOfTheRingslordOfTheRings()Loremlorem()Matzmatz()Medicalmedical()Musicmusic()Namename()Nationnation()Numbernumber()java.lang.Stringnumerify(java.lang.String numberString)Returns a string with the '#' characters in the parameter replaced with random digits between 0-9 inclusive.Optionsoptions()Overwatchoverwatch()PhoneNumberphoneNumber()Pokemonpokemon()PrincessBrideprincessBride()ProgrammingLanguageprogrammingLanguage()RandomServicerandom()java.lang.Stringregexify(java.lang.String regex)Generates a String that matches the given regular expression.Relationshipsrelationships()java.lang.Stringresolve(java.lang.String key)RickAndMortyrickAndMorty()Robinrobin()RockBandrockBand()Shakespeareshakespeare()SlackEmojislackEmoji()Spacespace()StarTrekstarTrek()Stockstock()Superherosuperhero()Teamteam()TwinPeakstwinPeaks()Universityuniversity()Weatherweather()Witcherwitcher()Yodayoda()Zeldazelda()
-
-
-
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)
-
Faker
public Faker(FakeValuesService fakeValuesService, RandomService random)
-
-
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 providedLocale.- Parameters:
locale- -Locale- Returns:
Faker(Locale)
-
instance
public static Faker instance(java.util.Random random)
Constructs Faker instance with providedRandom.- Parameters:
random- -Random- Returns:
Faker(Random)
-
instance
public static Faker instance(java.util.Locale locale, java.util.Random random)
Constructs Faker instance with providedLocaleandRandom.- Parameters:
locale- -Localerandom- -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 anumerify(String)and aletterify(String)over the incoming string.- Parameters:
string-- Returns:
-
bothify
public java.lang.String bothify(java.lang.String string, boolean isUpper)Applies both anumerify(String)and aletterify(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.
-
random
public RandomService random()
-
currency
public Currency currency()
-
ancient
public Ancient ancient()
-
app
public App app()
-
artist
public Artist artist()
-
avatar
public Avatar avatar()
-
aviation
public Aviation aviation()
-
music
public Music music()
-
name
public Name name()
-
number
public Number number()
-
internet
public Internet internet()
-
phoneNumber
public PhoneNumber phoneNumber()
-
pokemon
public Pokemon pokemon()
-
lorem
public Lorem lorem()
-
address
public Address address()
-
book
public Book book()
-
buffy
public Buffy buffy()
-
business
public Business business()
-
chuckNorris
public ChuckNorris chuckNorris()
-
color
public Color color()
-
commerce
public Commerce commerce()
-
company
public Company company()
-
crypto
public Crypto crypto()
-
hacker
public Hacker hacker()
-
idNumber
public IdNumber idNumber()
-
options
public Options options()
-
code
public Code code()
-
file
public File file()
-
finance
public Finance finance()
-
food
public Food food()
-
elderScrolls
public ElderScrolls elderScrolls()
-
gameOfThrones
public GameOfThrones gameOfThrones()
-
date
public DateAndTime date()
-
demographic
public Demographic demographic()
-
dog
public Dog dog()
-
educator
public Educator educator()
-
slackEmoji
public SlackEmoji slackEmoji()
-
shakespeare
public Shakespeare shakespeare()
-
space
public Space space()
-
superhero
public Superhero superhero()
-
bool
public Bool bool()
-
team
public Team team()
-
beer
public Beer beer()
-
university
public University university()
-
cat
public Cat cat()
-
stock
public Stock stock()
-
lordOfTheRings
public LordOfTheRings lordOfTheRings()
-
zelda
public Zelda zelda()
-
harryPotter
public HarryPotter harryPotter()
-
rockBand
public RockBand rockBand()
-
esports
public Esports esports()
-
friends
public Friends friends()
-
hipster
public Hipster hipster()
-
job
public Job job()
-
twinPeaks
public TwinPeaks twinPeaks()
-
rickAndMorty
public RickAndMorty rickAndMorty()
-
yoda
public Yoda yoda()
-
matz
public Matz matz()
-
witcher
public Witcher witcher()
-
dragonBall
public DragonBall dragonBall()
-
funnyName
public FunnyName funnyName()
-
hitchhikersGuideToTheGalaxy
public HitchhikersGuideToTheGalaxy hitchhikersGuideToTheGalaxy()
-
hobbit
public Hobbit hobbit()
-
howIMetYourMother
public HowIMetYourMother howIMetYourMother()
-
leagueOfLegends
public LeagueOfLegends leagueOfLegends()
-
overwatch
public Overwatch overwatch()
-
robin
public Robin robin()
-
starTrek
public StarTrek starTrek()
-
weather
public Weather weather()
-
lebowski
public Lebowski lebowski()
-
medical
public Medical medical()
-
country
public Country country()
-
animal
public Animal animal()
-
backToTheFuture
public BackToTheFuture backToTheFuture()
-
princessBride
public PrincessBride princessBride()
-
relationships
public Relationships relationships()
-
nation
public Nation nation()
-
dune
public Dune dune()
-
aquaTeenHungerForce
public AquaTeenHungerForce aquaTeenHungerForce()
-
programmingLanguage
public ProgrammingLanguage programmingLanguage()
-
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
-
-