Class BaseFaker
- All Implemented Interfaces:
BaseProviders,ProviderRegistration
- Direct Known Subclasses:
EntertainmentFaker,Faker,FoodFaker,HealthcareFaker,SportFaker,VideoGameFaker
- Author:
- ren
-
Constructor Summary
ConstructorsConstructorDescriptionBaseFaker(Locale locale, RandomService randomService) BaseFaker(FakeValuesService fakeValuesService, FakerContext context) BaseFaker(FakeValuesService fakeValuesService, FakerContext context, Predicate<Class<?>> whiteListPredicate) -
Method Summary
Modifier and TypeMethodDescriptionvoidAllows to add paths to files with custom data.voidAllows to add urls of files with custom data.Applies both anumerify(String)and aletterify(String)over the incoming string.Applies both anumerify(String)and aletterify(String)over the incoming string.<T> FakeSequence.Builder<T>final <T> FakeSequence.Builder<T>collection(Supplier<T>... suppliers) final <T> FakeSequence.Builder<T>collection(List<Supplier<T>> suppliers) Returns a string with generated csv based number of lines and column expressions.Returns a string with generated csv based number of lines and column expressions.<T> T<T> T<T> TGenerates a String by example.expression(String expression) Allows the evaluation of native YML expressions to allow you to build your own.final <B extends ProviderRegistration>
BgetFaker()static MethodgetMethod(AbstractProvider<?> ap, String methodName) <PR extends ProviderRegistration,AP extends AbstractProvider<PR>>
APgetProvider(Class<AP> clazz, Function<PR, AP> valueSupplier) static <PR extends ProviderRegistration,AP extends AbstractProvider<PR>>
APgetProvider(Class<AP> clazz, Function<PR, AP> valueSupplier, PR faker) Deprecated.Returns a string with the '?'Returns a string with the '?'Returns a string with the '#' characters in the parameter replaced with random digits between 0-9 inclusive or random digits in the range from 1-9 when Ø (not zero) is used.static <T> Tstatic <T> Trandom()Generates a String that matches the given regular expression.<T> FakeSequence.Builder<T>stream()final <T> FakeSequence.Builder<T>final <T> FakeSequence.Builder<T>templatify(String string, char char2replace, String... options) Returns a string with the char2replace characters in the parameter replaced with random option from available options.templatify(String string, Map<Character, String[]> optionsMap) Returns a string with the characters in the keys of optionsMap parameter replaced with random option from values.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.datafaker.providers.base.BaseProviders
address, ancient, animal, app, appliance, artist, australia, aviation, aws, azure, barcode, bloodtype, book, bool, brand, business, camera, cannabis, cat, chiquito, cnpj, code, coin, color, commerce, community, company, compass, computer, construction, cosmere, country, cpf, credentials, cryptoCoin, cultureSeries, currency, date, dcComics, demographic, device, dog, domain, drivingLicense, drone, dungeonsAndDragons, duration, educator, electricalComponents, emoji, famousLastWords, file, finance, financialTerms, funnyName, garmentSize, gender, greekPhilosopher, hacker, hashing, hipster, hobby, hololive, horse, house, idNumber, image, industrySegments, internet, job, kpop, languageCode, largeLanguageModel, locality, location, lorem, marketing, matz, mbti, measurement, medical, military, money, mood, mountain, mountaineering, music, name, nation, natoPhoneticAlphabet, nigeria, number, olympicSport, passport, phoneNumber, photography, planet, programmingLanguage, pronouns, relationships, restaurant, robin, rockBand, science, shakespeare, sip, size, slackEmoji, space, stock, subscription, superhero, team, text, time, timeAndDate, tire, transport, twitter, unique, university, vehicle, verb, weather, word, yoda, zodiacMethods inherited from interface net.datafaker.providers.base.ProviderRegistration
getProvider, options
-
Constructor Details
-
BaseFaker
public BaseFaker() -
BaseFaker
-
BaseFaker
-
BaseFaker
-
BaseFaker
-
BaseFaker
-
BaseFaker
public BaseFaker(FakeValuesService fakeValuesService, FakerContext context, Predicate<Class<?>> whiteListPredicate)
-
-
Method Details
-
getContext
- Specified by:
getContextin interfaceProviderRegistration
-
doWith
-
doWith
-
doWith
-
numerify
Returns a string with the '#' characters in the parameter replaced with random digits between 0-9 inclusive or random digits in the range from 1-9 when Ø (not zero) is used.For example, the string "ABC##EFG" could be replaced with a string like "ABC99EFG" and the string "Ø##" with a value like "149".
- Specified by:
numerifyin interfaceProviderRegistration- Parameters:
numberString- Template for string generation- Returns:
- Generated string
-
letterify
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".
- Specified by:
letterifyin interfaceProviderRegistration- Parameters:
letterString- Template for string generation- Returns:
- Generated string.
-
letterify
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".
- Specified by:
letterifyin interfaceProviderRegistration
-
bothify
Applies both anumerify(String)and aletterify(String)over the incoming string.- Specified by:
bothifyin interfaceProviderRegistration
-
bothify
Applies both anumerify(String)and aletterify(String)over the incoming string.- Specified by:
bothifyin interfaceProviderRegistration
-
regexify
Generates a String that matches the given regular expression.- Specified by:
regexifyin interfaceProviderRegistration
-
examplify
Generates a String by example. The output string will have the same pattern as the input string.For example: "AAA" becomes "KRA" "abc" becomes "uio" "948" becomes "345" "A19c" becomes "Z20d"
- Specified by:
examplifyin interfaceProviderRegistration- Parameters:
example- The input string- Returns:
- The output string based on the input pattern
-
templatify
Returns a string with the char2replace characters in the parameter replaced with random option from available options.For example, the string "ABC??EFG" could be replaced with a string like "ABCtestтестEFG" if passed options are new String[]{"test", "тест"}.
- Specified by:
templatifyin interfaceProviderRegistration- Parameters:
string- Template for string generationchar2replace- Char to replaceoptions- Options to use while filling the template- Returns:
- Generated string
-
templatify
Returns a string with the characters in the keys of optionsMap parameter replaced with random option from values.For example, the string "ABC$$EFG" could be replaced with a string like "ABCtestтестEFG" if passed for key '$' there is value new String[]{"test", "тест"} in optionsMap
- Specified by:
templatifyin interfaceProviderRegistration- Parameters:
string- Template for string generationoptionsMap- Map with replacement rules- Returns:
- Generated string
-
csv
Returns a string with generated csv based number of lines and column expressions. This method will use comma as default delimiter, always prints header and double quote as default quote.For example, it could generate "name_column","last_name_column" "Sabrina","Kihn"
for expression
faker.expression("#{csv '1','name_column','#{Name.first_name}','last_name_column','#{Name.last_name}'}");- Specified by:
csvin interfaceProviderRegistration- Parameters:
limit- Number of linescolumnExpressions- Even number of expressions. The odd numbers args are used for columns names, and even for column values.- Returns:
- Generated string
-
csv
public String csv(String separator, char quote, boolean withHeader, int limit, String... columnExpressions) Returns a string with generated csv based number of lines and column expressions.For example, it could generate "Thad" ### "Crist" "Kathryne" ### "Wuckert" "Sybil" ### "Connelly"
for expression
faker.expression("#{csv ' ### ','"','false','3','name_column','#{Name.first_name}','last_name_column','#{Name.last_name}'}");- Specified by:
csvin interfaceProviderRegistration- Parameters:
separator- Delimiter to usequote- Quote to usewithHeader- Print header or notlimit- Number of linescolumnExpressions- Even number of expressions. The odd numbers args are used for columns names, and even for column values.- Returns:
- Generated string
-
json
- Specified by:
jsonin interfaceProviderRegistration
-
jsona
- Specified by:
jsonain interfaceProviderRegistration
-
random
- Specified by:
randomin interfaceProviderRegistration
-
fakeValuesService
- Specified by:
fakeValuesServicein interfaceProviderRegistration
-
addPath
Allows to add paths to files with custom data. Data should be in YAML format.- Specified by:
addPathin interfaceProviderRegistration- Parameters:
locale- the locale for which a path is going to be added.path- path to a file with YAML structure- Throws:
IllegalArgumentException- in case of invalid path
-
addUrl
Allows to add urls of files with custom data. Data should be in YAML format.- Specified by:
addUrlin interfaceProviderRegistration- Parameters:
locale- the locale for which an url is going to be added.url- url of a file with YAML structure- Throws:
IllegalArgumentException- in case of invalid url
-
populate
-
populate
-
getProvider
public <PR extends ProviderRegistration,AP extends AbstractProvider<PR>> AP getProvider(Class<AP> clazz, Function<PR, AP> valueSupplier) - Specified by:
getProviderin interfaceProviderRegistration
-
getProvider
@Deprecated public static <PR extends ProviderRegistration,AP extends AbstractProvider<PR>> AP getProvider(Class<AP> clazz, Function<PR, AP> valueSupplier, PR faker) Deprecated.Use non-static methodgetProvider(Class, Function)instead.This method is not needed anymore, don't use it. -
collection
- Returns:
- builder to build
FakeCollection
-
collection
-
collection
-
stream
- Returns:
- builder to build
FakeStream
-
stream
-
stream
-
resolve
- Specified by:
resolvein interfaceProviderRegistration
-
resolve
- Specified by:
resolvein interfaceProviderRegistration
-
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'}
- Specified by:
expressionin interfaceProviderRegistration- Parameters:
expression- (see examples above)- Returns:
- the evaluated string expression
- Throws:
RuntimeException- if unable to evaluate the expression
-
getFaker
- Specified by:
getFakerin interfaceProviderRegistration
-
getMethod
-
toString
-
getProvider(Class, Function)instead.