### Initialize Dummy4j with Default Configuration Source: https://github.com/daniel-frak/dummy4j/blob/master/configuration.md Use the no-args constructor for a default configuration. No setup or imports are required beyond the Dummy4j class itself. ```java Dummy4j dummy = new Dummy4j(); ``` -------------------------------- ### Run Mutation Tests for Entire Project Source: https://github.com/daniel-frak/dummy4j/blob/master/CONTRIBUTING.md Execute mutation tests for the entire dummy4j project. This is the most thorough but time-consuming method. Ensure you have Maven installed. ```shell mvn clean test-compile org.pitest:pitest-maven:mutationCoverage -Ppitest-config ``` -------------------------------- ### YAML Example with Nested Expressions Source: https://github.com/daniel-frak/dummy4j/blob/master/extending-dummy4j.md This YAML defines custom data including a list of strings, a pattern for generating numbers, and a composite expression that combines values from other definitions. ```yaml en: my_definitions: thing1: [ "abc", "def", "ghijk" ] thing2: [ "###-###" ] any_thing: [ "#{my_definitions.thing1}: #{my_definitions.thing2}" ] ``` -------------------------------- ### Generate random enum values Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `nextEnum(...)` by providing an enum class to get a random value from that enum. ```java MyEnum randomEnum = dummy.nextEnum(MyEnum.class); ``` -------------------------------- ### Basic Dummy4j Instantiation Source: https://context7.com/daniel-frak/dummy4j/llms.txt Initialize the library and generate basic data like country names. ```java // Basic instantiation Dummy4j dummy = new Dummy4j(); // Get a random country name String country = dummy.nation().country(); System.out.println(country); // Output: "Canada" ``` -------------------------------- ### Configure Dummy4j with Seed, Locales, and Paths Source: https://github.com/daniel-frak/dummy4j/blob/master/configuration.md Initialize Dummy4j using a constructor or builder with a specific seed, a list of locales, and paths to custom data files or directories. Null values for parameters will result in default values being used. ```java // Constructor Dummy4j dummy = new Dummy4j(123456L, Collections.singletonList("en"), Arrays.asList("my/custom/path", "dummy4j/some_specific_file.yml")); ``` ```java // Builder Dummy4j dummy = new Dummy4jBuilder() .seed(123456L) .locale(Collections.singletonList("en")) .paths(Arrays.asList("my/custom/path", "dummy4j")) .build(); ``` -------------------------------- ### Initialize and Use Dummy4j Source: https://github.com/daniel-frak/dummy4j/blob/master/index.md Instantiate the Dummy4j object to begin generating random data, such as country names. ```java Dummy4j dummy = new Dummy4j(); String randomCountry = dummy.nation().country(); ``` -------------------------------- ### Generate dummy data with Dummy4j Source: https://github.com/daniel-frak/dummy4j/blob/master/README.md Demonstrates common usage patterns for generating random data, handling collections, ensuring uniqueness, and resolving expressions. ```java Dummy4j dummy = new Dummy4j(); String fullName = dummy.name().fullName(); String researchPaperTitle = dummy.researchPaper().title(); String sixSentenceParagraph = dummy.lorem().paragraph(6); String romanNumeralsBetweenOneAndFifteen = dummy.numerals().roman(1, 15); int betweenFiveAndTenInclusive = dummy.number().nextInt(5, 10); boolean trueOrFalse = dummy.nextBoolean(); LocalDate birthdayBetween18And35 = dummy.dateAndTime().birthday(18, 35); LocalDateTime upTo100YearsInThePast = dummy.dateAndTime().past(100, ChronoUnit.YEARS); LocalDateTime upTo25YearsFrom1800 = dummy.dateAndTime().after( LocalDateTime.parse("1800-01-01T00:00:00"), 25, ChronoUnit.YEARS); MyEnum randomEnum = dummy.nextEnum(MyEnum.class); String thisValueMightBeNull = dummy.chance(1, 3, () -> "hello"); String thisValueWillBeUnique = dummy.unique().value("fullNameGroup", () -> dummy.name().fullName()); List fiveNames = dummy.listOf(5, () -> dummy.name().fullName()); Set fourCities = dummy.setOf(4, () -> dummy.address().city()); String nameOrCity = dummy.oneOf(() -> dummy.name().fullName(), () -> dummy.address().city()); String elementFromArray = dummy.oneOf(new String[]{ "one", "two", "three" }); String elementFromVarArgs = dummy.oneOf("one", "two", "three"); String elementFromCollection = dummy.oneOf(Arrays.asList("one", "two", "three")); dummy.unique().within(() -> dummy.name().fullName(), name -> { // These names will only be unique within the context of this consumer List tenLocallyUniqueNames = dummy.listOf(10, name); }); List tenLocallyUniqueNames = dummy.unique().of(() -> dummy.name().fullName(), name -> dummy.listOf(10, name)); // This resolves an expression, finding the appropriate values in yml files. // Normally, this should be hidden away under a custom method // (e.g. customDummy.maleAndFemaleNames()). String resolvedExpression = dummy4j.expressionResolver() .resolve("#{name.male_first_name}, #{name.female_first_name}"); // This finds and lists all methods containing the word "title": String searchResult = dummy4j.find("title"); ``` -------------------------------- ### Configure Dummy4j with Builder Source: https://context7.com/daniel-frak/dummy4j/llms.txt Use the builder pattern to set seeds for reproducibility, define locales, and specify custom definition paths. ```java // Using the builder for configuration Dummy4j dummy = new Dummy4jBuilder() .seed(123456L) // Set seed for reproducible results .locale("en", "de") // Set locales (English, German) .paths("dummy4j", "my/custom/definitions") // Add custom definition paths .build(); // With same seed, always generates the same sequence String name1 = dummy.name().fullName(); String name2 = dummy.name().fullName(); System.out.println(name1); // Always: "Mr. Braden Freeman" System.out.println(name2); // Always: "Niki Faulkner Durham" ``` -------------------------------- ### Advanced Dummy4j Configuration with Custom Dependencies Source: https://github.com/daniel-frak/dummy4j/blob/master/configuration.md Configure Dummy4j by injecting custom implementations of its dependencies like RandomService, YamlFileDefinitionProvider, and ExpressionResolver. This allows for fine-grained control over the generation process. ```java RandomService randomService = new DefaultRandomService(123456L); YamlFileDefinitionProvider definitionProvider = YamlFileDefinitionProvider.withPaths( Arrays.asList("dummy4j", "my/custom/path")); ExpressionResolver expressionResolver = new DefaultExpressionResolver(Collections.singletonList("en"), randomService, definitionProvider); Dummy4j dummy = new Dummy4j(expressionResolver, randomService); ``` -------------------------------- ### Dummy4j Convenience Methods Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md A collection of utility methods for searching, randomizing, and generating unique or collection-based data. ```APIDOC ## Method: find(String searchString) ### Description Locates available methods within the Dummy4j instance that contain the provided search string. ### Parameters - **searchString** (String) - Required - The string to search for within method names. ### Request Example ```java dummy4j.find("name"); ``` ## Method: chance(int numerator, int denominator, Supplier supplier) ### Description Returns the value from the supplier based on a probability defined by the numerator and denominator. ### Parameters - **numerator** (int) - Required - The number of successful outcomes. - **denominator** (int) - Required - The total number of possible outcomes. - **supplier** (Supplier) - Required - The function providing the value. ## Method: oneOf(T[] array / Collection collection / Supplier... suppliers) ### Description Returns a random element from the provided array, collection, or a random result from an array of suppliers. ## Method: unique().value(String group, Supplier supplier) ### Description Generates a globally unique value within a specified uniqueness group for the lifetime of the Dummy4j instance. ## Method: listOf(int size, Supplier supplier) ### Description Generates a list of items of a specified size using the provided supplier. ## Method: nextEnum(Class enumClass) ### Description Generates a random value from the provided Enum class. ``` -------------------------------- ### Generate Internet Data with Builders Source: https://context7.com/daniel-frak/dummy4j/llms.txt Generate emails, usernames, passwords, and URLs using Dummy4j. Utilizes builder patterns for customization of generated internet data. Requires java.net.URL import. ```java import java.net.URL; Dummy4j dummy = new Dummy4j(); // Basic generation String email = dummy.internet().email(); // "zoe.anderson@example.com" String username = dummy.internet().username(); // "zoe-anderson" String password = dummy.internet().password(); // Random password URL url = dummy.internet().url(); // Random URL // Email builder with customization String customEmail = dummy.internet().emailBuilder() .withSubAddresses("custom-tag") .safe() .build(); // Output: "zoe.anderson+custom-tag@example.com" // Password builder String strongPassword = dummy.internet().passwordBuilder() .withDigits() .withUpperCaseChars() .withSpecialChars() .withMinLength(16) .build(); // URL builder URL customUrl = dummy.internet().urlBuilder() .withPort(8080) .withQueryParams() .minLength(50) .build(); System.out.println("Email: " + email); System.out.println("Custom Email: " + customEmail); System.out.println("Strong Password: " + strongPassword); System.out.println("URL: " + customUrl); ``` -------------------------------- ### Use custom Dummy4j API Source: https://github.com/daniel-frak/dummy4j/blob/master/extending-dummy4j.md Instantiate the custom class and invoke the newly defined methods to retrieve dummy data. ```java CustomDummy4j dummy = new CustomDummy4j(); System.out.println(dummy.myDefinitions().anyThing()); ``` -------------------------------- ### Extend Dummy4j with Custom Definitions Source: https://context7.com/daniel-frak/dummy4j/llms.txt Define custom data in YAML and create a subclass of Dummy4j to expose the new data via a clean API. ```yaml # resources/dummy4j/my_definitions.yml en: my_definitions: product_names: ["Widget", "Gadget", "Gizmo", "Device"] product_codes: ["PRD-###-###"] full_product: ["#{my_definitions.product_names}: #{my_definitions.product_codes}"] ``` ```java // Custom Dummy4j extension public class CustomDummy4j extends Dummy4j { private final ProductDummy products; public CustomDummy4j() { products = new ProductDummy(this); } public ProductDummy products() { return products; } public static class ProductDummy { private final CustomDummy4j dummy; public ProductDummy(CustomDummy4j dummy) { this.dummy = dummy; } public String name() { return dummy.expressionResolver().resolve("#{my_definitions.product_names}"); } public String code() { return dummy.expressionResolver().resolve("#{my_definitions.product_codes}"); } public String full() { return dummy.expressionResolver().resolve("#{my_definitions.full_product}"); } } } // Usage CustomDummy4j dummy = new CustomDummy4j(); System.out.println(dummy.products().name()); // "Widget" System.out.println(dummy.products().code()); // "PRD-123-456" System.out.println(dummy.products().full()); // "Gadget: PRD-789-012" ``` -------------------------------- ### Add Dummy4j Maven Dependency Source: https://github.com/daniel-frak/dummy4j/blob/master/index.md Include this dependency in your pom.xml to integrate the library into your project. ```xml dev.codesoapbox dummy4j 0.11.0 ``` -------------------------------- ### Add Maven Dependency Source: https://context7.com/daniel-frak/dummy4j/llms.txt Include the Dummy4j dependency in your project's pom.xml file. ```xml dev.codesoapbox dummy4j 0.11.0 ``` -------------------------------- ### Generate Finance Data with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Use Dummy4j to generate various financial data like currency codes, names, symbols, credit card numbers, IBANs, and prices. Supports custom formatting for credit cards and IBANs. ```java Dummy4j dummy = new Dummy4j(); // Currency data String currencyCode = dummy.finance().currencyCode(); // "USD" String currencyName = dummy.finance().currencyName(); // "US Dollar" String currencySymbol = dummy.finance().currencySymbol(); // "$" String cryptoCode = dummy.finance().cryptoCurrencyCode(); // "BTC" String cryptoName = dummy.finance().cryptoCurrencyName(); // "Bitcoin" // Credit card generation String creditCardNumber = dummy.finance().creditCardNumber(); // "4150 2591 8277 4861" CreditCardProvider provider = dummy.finance().creditCardProvider(); // VISA, MASTERCARD, etc. CreditCard creditCard = dummy.finance().creditCard(); // Credit card with builder String unformattedCard = dummy.finance().creditCardNumberBuilder() .withoutFormatting() .build(); // Output: "4150259182774861" // Bank account numbers String bic = dummy.finance().bic(); // "RHBHPLPW123" String iban = dummy.finance().iban(); // "GL2530157608510356" String formattedIban = dummy.finance().ibanBuilder() .withCountry(BankAccountCountry.GERMANY) .formatted() .build(); // Output: "DE89 3704 0044 0532 0130 00" // Price generation String price = dummy.finance().price(); // "12.34" String priceWithCurrency = dummy.finance().priceBuilder() .withCurrency("USD") .build(); // Output: "USD 12.34" // Bitcoin address String bitcoinAddress = dummy.finance().bitcoinAddress(); // "bc1qarsrrr7xfkvy5643ydnw9re59gtzzwf5mdq" ``` -------------------------------- ### Access Specialized Domain Dummies Source: https://context7.com/daniel-frak/dummy4j/llms.txt Utilize built-in specialized dummy classes for domains like education, medical, and sci-fi. ```java Dummy4j dummy = new Dummy4j(); // Book dummy String bookTitle = dummy.book().title(); String bookGenre = dummy.book().genre(); String publisher = dummy.book().publisher(); // Research paper dummy String paperTitle = dummy.researchPaper().title(); String paperTitleSocial = dummy.researchPaper().titleSocialSciences(); // Education dummy String university = dummy.education().university(); String major = dummy.education().major(); String degree = dummy.education().degree(); // Medical dummy String occupation = dummy.medical().occupation(); String discipline = dummy.medical().discipline(); String condition = dummy.medical().condition(); // Sci-fi dummy String spaceship = dummy.scifi().spaceship(); String planet = dummy.scifi().planet(); String alien = dummy.scifi().species(); // Numerals dummy String roman = dummy.numerals().roman(1, 100); // "XLII" // NATO phonetic alphabet String nato = dummy.natoPhoneticAlphabet().word(); // "Alpha" // Business dummy String productName = dummy.business().productName(); String department = dummy.business().department(); ``` -------------------------------- ### Discover API Methods Source: https://context7.com/daniel-frak/dummy4j/llms.txt Search for available methods in the Dummy4j API using keyword filtering. ```java Dummy4j dummy = new Dummy4j(); // Find all methods containing "name" String methods = dummy.find("name"); System.out.println(methods); /* Output: Dummy4j.color().name() Dummy4j.color().primaryName() Dummy4j.finance().creditCard().getOwnerName() Dummy4j.finance().currencyName() Dummy4j.internet().username() Dummy4j.name() Dummy4j.name().firstName() Dummy4j.name().lastName() Dummy4j.name().fullName() ... */ // Find methods related to "address" String addressMethods = dummy.find("address"); System.out.println(addressMethods); ``` -------------------------------- ### Generate collections of items Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `listOf(...)` and `setOf(...)` for quickly creating collections of specified size with generated items. ```java List fiveNames = dummy.listOf(5, () -> dummy.name().fullName()); Set fourCities = dummy.setOf(4, () -> dummy.address().city()); ``` -------------------------------- ### Run Mutation Tests for Specific Classes Source: https://github.com/daniel-frak/dummy4j/blob/master/CONTRIBUTING.md Execute mutation tests for a specific package or set of classes within the dummy4j project. This is useful for targeted testing. Replace 'the.package.i.changed' with the actual package name. ```shell mvn clean test-compile org.pitest:pitest-maven:mutationCoverage -Ppitest-config -DtargetClasses="the.package.i.changed.*" ``` -------------------------------- ### Generate Nation and Language Data Source: https://context7.com/daniel-frak/dummy4j/llms.txt Use Dummy4j to generate country names, codes, nationalities, and language codes in different ISO standards. Supports common language subsets. ```java Dummy4j dummy = new Dummy4j(); // Country data String country = dummy.nation().country(); // "Germany" String countryCode = dummy.nation().countryCode(); // "DE" String nationality = dummy.nation().nationality(); // "German" // Language data String language = dummy.nation().language(); // "German" String langCodeTwoLetter = dummy.nation().languageCodeTwoLetter(); // "de" (ISO 639-1) String langCodeThreeLetter = dummy.nation().languageCodeThreeLetter(); // "deu" (ISO 639-2) // Common languages subset String commonLang = dummy.nation().languageCommon(); // "English" String commonLangCode = dummy.nation().languageCodeTwoLetterCommon(); // "en" ``` -------------------------------- ### Generate Collections with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Create lists and sets of random items using Dummy4j. You can specify the size of the collection and provide a supplier function to generate each item. This is useful for generating collections of names, cities, emails, or complex objects. ```java Dummy4j dummy = new Dummy4j(); // Generate list of items List fiveNames = dummy.listOf(5, () -> dummy.name().fullName()); // ["Mr. John Smith", "Jane Doe", "Dr. Alice Brown", ...] // Generate set of unique items Set fourCities = dummy.setOf(4, () -> dummy.address().city()); // {"New York", "London", "Paris", "Tokyo"} // Combined with other dummies List tenEmails = dummy.listOf(10, () -> dummy.internet().email()); // Generate complex objects List
addresses = dummy.listOf(3, () -> dummy.address().full()); for (String name : fiveNames) { System.out.println("Name: " + name); } ``` -------------------------------- ### Generate Lorem Ipsum Placeholder Text Source: https://context7.com/daniel-frak/dummy4j/llms.txt Generate random characters, words, sentences, and paragraphs for placeholder text using Dummy4j. Sentences and paragraphs can be generated with specific word or sentence counts. ```java Dummy4j dummy = new Dummy4j(); // Character and word generation String chars = dummy.lorem().characters(10); // "abcdefghij" String word = dummy.lorem().word(); // "lorem" // Sentence generation String sentence = dummy.lorem().sentence(); // Random sentence (3-10 words) String sentence5 = dummy.lorem().sentence(5); // 5-word sentence String sentenceRange = dummy.lorem().sentence(3, 7); // 3-7 word sentence // Paragraph generation String paragraph = dummy.lorem().paragraph(); // Random paragraph (3-10 sentences) String paragraph6 = dummy.lorem().paragraph(6); // 6-sentence paragraph System.out.println("Word: " + word); System.out.println("Sentence: " + sentence); System.out.println("Paragraph: " + paragraph6); ``` -------------------------------- ### Resolving Custom Definitions in Java Source: https://github.com/daniel-frak/dummy4j/blob/master/extending-dummy4j.md Instantiate Dummy4j and use its expression resolver to access your custom definitions. Ensure custom definition files are placed in the `resources/dummy4j` directory. ```java Dummy4j dummy = new Dummy4j(); System.out.println(dummy.expressionResolver().resolve("#{my_definitions.any_thing}")); ``` -------------------------------- ### Apply chance-based logic Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `chance(...)` to introduce randomness in filling object fields. It takes a numerator, denominator, and a supplier function. ```java String thisValueMightBeNull = dummy4j.chance(1, 3, () -> "hello"); ``` -------------------------------- ### Generate Optional Values with Dummy4j Chance Method Source: https://context7.com/daniel-frak/dummy4j/llms.txt Use the `chance` method to generate values with a specified probability. This is useful for creating optional fields or simulating probabilistic events. It returns a value based on the given numerator and denominator, or null if the chance fails. ```java Dummy4j dummy = new Dummy4j(); // 1-in-3 chance to return "hello", otherwise null String mightBeNull = dummy.chance(1, 3, () -> "hello"); // 1-in-2 chance (50%) to return true boolean fiftyFifty = dummy.chance(1, 2); // Practical usage: optional fields Person person = new Person(); person.setName(dummy.name().fullName()); person.setEmail(dummy.internet().email()); person.setMiddleName(dummy.chance(1, 4, () -> dummy.name().firstName())); // 25% have middle name person.setPhoneNumber(dummy.chance(3, 4, () -> "555-" + dummy.number().nextInt(1000, 9999))); // 75% have phone System.out.println("Might be null: " + mightBeNull); System.out.println("Has phone: " + (person.getPhoneNumber() != null)); ``` -------------------------------- ### Extend Dummy4j for custom definitions Source: https://github.com/daniel-frak/dummy4j/blob/master/extending-dummy4j.md Create a custom class extending Dummy4j to encapsulate new definition methods. This implementation uses an inner class to resolve expressions via the expressionResolver. ```java public class CustomDummy4j extends Dummy4j { private final MyDefinitionsDummy myDefinitions; public CustomDummy4j() { myDefinitions = new MyDefinitionsDummy(this); } public MyDefinitionsDummy myDefinitions() { return myDefinitions; } public static class MyDefinitionsDummy { private final CustomDummy4j dummy4j; public MyDefinitionsDummy(CustomDummy4j dummy4j) { this.dummy4j = dummy4j; } public String thing1() { return dummy4j.expressionResolver.resolve("#{my_definitions.thing1}"); } public String thing2() { return dummy4j.expressionResolver.resolve("#{my_definitions.thing2}"); } public String anyThing() { return dummy4j.expressionResolver.resolve("#{my_definitions.any_thing}"); } } } ``` -------------------------------- ### Generate Colors with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Generate colors in various formats including named colors, hex, RGB, HSB, HSL, and CMYK. Supports Java AWT Color objects and custom color models. ```java import java.awt.Color; Dummy4j dummy = new Dummy4j(); // Named colors String primaryColor = dummy.color().primaryName(); // "blue" String basicColor = dummy.color().basicName(); // "orange" String additionalColor = dummy.color().additionalName(); // "scarlet" String anyColor = dummy.color().name(); // "magenta" // Hex colors String hex = dummy.color().hex(); // "#b58502" String hexAlpha = dummy.color().hexAlpha(); // "#e7e247d5" // Java AWT Color Color rgb = dummy.color().rgb(); // java.awt.Color[r=181,g=133,b=2] Color rgba = dummy.color().rgba(); // java.awt.Color[r=226,g=71,b=213], alpha=231 // HSB/HSL colors HSB hsb = dummy.color().hsb(); // hsb(150.17, 34%, 34%) HSBA hsba = dummy.color().hsba(); // hsba(150.17, 34%, 34%, 0.34) HSL hsl = dummy.color().hsl(); // hsl(150.17, 34%, 34%) HSLA hsla = dummy.color().hsla(); // hsla(150.17, 34%, 34%, 0.34) // CMYK color CMYK cmyk = dummy.color().cmyk(); // cmyk(15%, 34%, 20%, 75%) System.out.println("Hex: " + hex); System.out.println("RGB: " + rgb); System.out.println("HSL: " + hsl); ``` -------------------------------- ### Generate Password with Builder Pattern Source: https://github.com/daniel-frak/dummy4j/blob/master/philosophy.md Generates a password with specific criteria using the builder pattern. Use when default password generation is insufficient and custom requirements are needed. ```java dummy.internet().passwordBuilder() .withDigits() .withSpecialChars() .withLength(20) .build(); ``` -------------------------------- ### Default Password Generation Source: https://github.com/daniel-frak/dummy4j/blob/master/philosophy.md Generates a default password. This is the standard method for simple password generation. ```java dummy.internet().password(); ``` -------------------------------- ### YAML Structure for Custom Definitions Source: https://github.com/daniel-frak/dummy4j/blob/master/extending-dummy4j.md Define your custom data using YAML files. The structure includes a locale, followed by a path to a key, which holds a list of values. ```yaml locale: path: to: key: [ "value1", "value2", "value3" ] ``` -------------------------------- ### Generate Random Names Source: https://context7.com/daniel-frak/dummy4j/llms.txt Generate various name components including prefixes, first names, last names, and full names. ```java Dummy4j dummy = new Dummy4j(); // Generate name components String prefix = dummy.name().prefix(); // "Mrs." String firstName = dummy.name().firstName(); // "Zoe" String lastName = dummy.name().lastName(); // "Anderson" String fullName = dummy.name().fullName(); // "Mr. Braden Freeman" String fullWithMiddle = dummy.name().fullNameWithMiddle(); // "Niki Faulkner Durham" System.out.println("Prefix: " + prefix); System.out.println("First Name: " + firstName); System.out.println("Last Name: " + lastName); System.out.println("Full Name: " + fullName); System.out.println("Full Name with Middle: " + fullWithMiddle); ``` -------------------------------- ### Find a specific method Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `find(...)` to locate methods containing a given search string. It returns a list of matching method signatures. ```java String message = dummy4j.find("name"); ``` -------------------------------- ### Generate Identifiers with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Generate various standard identifiers such as UUIDs, ISBNs, ISSNs, GTINs, IMEI numbers, ASINs, and SSCCs using Dummy4j. Supports builders for custom identifier formats. ```java import java.util.UUID; Dummy4j dummy = new Dummy4j(); // UUID UUID uuid = dummy.identifier().uuid(); // c4ca4238-a0b9-3382-8dcc-509a6f75849b // Book/Publication identifiers String issn = dummy.identifier().issn(); // "1234-567X" Isbn isbn = dummy.identifier().isbn(); // 978-0-306-40615-6 Ismn ismn = dummy.identifier().ismn(); // 979 0 2712 7923 6 // ISBN builder String isbn10 = dummy.identifier().isbnBuilder() .withType(IsbnType.ISBN_10) .withoutSeparator() .build(); // Output: "9706077057" // Trade identifiers (GTINs/EANs) String ean8 = dummy.identifier().ean8(); // "59907824" String ean13 = dummy.identifier().ean13(); // "7755838708484" String gtin14 = dummy.identifier().gtin14(); // "37735089220257" String upc = dummy.identifier().upc(); // "001543032542" // Device identifiers String imei = dummy.identifier().imei(); // "98-601561-419726-3" String imeisv = dummy.identifier().imeisv(); // "99-993671-425488-39" String tac = dummy.identifier().tac(); // "52-870587" // Other identifiers String asin = dummy.identifier().asin(); // "B00AA74928" String sscc = dummy.identifier().sscc(); // "(00)247266005821394706" String orcid = dummy.identifier().orcid(); // "6994-0298-2935-3670" String isni = dummy.identifier().isni(); // "2975484076158599" // GS1-128 barcode String gs1 = dummy.identifier().gs1Dash128(); // "(00)930815721808015600(30)548855(20)41" ``` -------------------------------- ### Generate Random Dates and Times Source: https://context7.com/daniel-frak/dummy4j/llms.txt Generate random dates, birthdays, and timestamps using Dummy4j. Supports generation within specified ranges or relative to the current time. Requires java.time imports. ```java import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; Dummy4j dummy = new Dummy4j(); // Any random date/time LocalDateTime anyDateTime = dummy.dateAndTime().any(); // Birthday generation LocalDate birthday = dummy.dateAndTime().birthday(); // 18-80 years old LocalDate birthday30 = dummy.dateAndTime().birthday(30); // Exactly 30 years old LocalDate birthday25to35 = dummy.dateAndTime().birthday(25, 35); // Between 25-35 years old // Date ranges LocalDateTime start = LocalDateTime.parse("2020-01-01T00:00:00"); LocalDateTime end = LocalDateTime.parse("2023-12-31T23:59:59"); LocalDateTime between = dummy.dateAndTime().between(start, end); // Past and future dates LocalDateTime past100Years = dummy.dateAndTime().past(100, ChronoUnit.YEARS); LocalDateTime future30Days = dummy.dateAndTime().future(30, ChronoUnit.DAYS); // Relative to a reference date LocalDateTime refDate = LocalDateTime.parse("1800-01-01T00:00:00"); LocalDateTime after1800 = dummy.dateAndTime().after(refDate, 25, ChronoUnit.YEARS); LocalDateTime before1800 = dummy.dateAndTime().before(refDate, 10, ChronoUnit.YEARS); System.out.println("Birthday: " + birthday25to35); System.out.println("100 years ago: " + past100Years); System.out.println("30 days from now: " + future30Days); ``` -------------------------------- ### Generate Unique Values with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Ensure generated values are unique within a specified scope. Dummy4j supports global uniqueness across the instance lifetime and local uniqueness within a specific block of code or collection generation. ```java Dummy4j dummy = new Dummy4j(); // Global uniqueness - values are unique for the lifetime of Dummy4j instance for (int i = 0; i < 10; i++) { String uniqueName = dummy.unique().value("fullNameGroup", () -> dummy.name().fullName()); System.out.println(uniqueName); // Each name is unique within "fullNameGroup" } // Local uniqueness - generate a collection of locally unique values List tenUniqueNames = dummy.unique().of( () -> dummy.name().fullName(), name -> dummy.listOf(10, name) ); System.out.println(tenUniqueNames); // All 10 names are unique // Local uniqueness within a code block dummy.unique().within(() -> dummy.name().fullName(), name -> { for (int i = 0; i < 10; i++) { System.out.println(name.get()); // Each call returns unique value } }); ``` -------------------------------- ### YAML for Modular Data Generation Source: https://github.com/daniel-frak/dummy4j/blob/master/philosophy.md Defines modular data generation using YAML, allowing for greater variety by referencing other definitions. Useful for localizations and complex data structures. ```yaml title_history: [ "An Introduction to the History of #{research_paper.title_history_of}", "Causes of #{research_paper.title_history_cause_of}", "..." ] title_history_of: [ "#{nation.country}", "#{address.city}", "..." ] title_history_cause_of: [ "World War I", "World War II", "the Battle of #{address.city}", "..." ] ``` -------------------------------- ### Generate Address Data Source: https://context7.com/daniel-frak/dummy4j/llms.txt Retrieve individual address components or a complete address object. ```java Dummy4j dummy = new Dummy4j(); // Individual address components String city = dummy.address().city(); // "North Austinshire" String street = dummy.address().street(); // "10 Amos Alley" String postCode = dummy.address().postCode(); // "1234-55" String country = dummy.address().country(); // "Canada" String countryCode = dummy.address().countryCode(); // "CA" // Complete address object Address fullAddress = dummy.address().full(); System.out.println(fullAddress.getStreet()); // "10 Amos Alley" System.out.println(fullAddress.getPostCode()); // "1234-55" System.out.println(fullAddress.getCity()); // "North Austinshire" System.out.println(fullAddress.getCountry()); // "Canada" ``` -------------------------------- ### Generate Random Numbers with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Use Dummy4j to generate various types of random numbers, including integers, longs, floats, and doubles. Specify ranges or bounds as needed. Booleans can also be generated. ```java Dummy4j dummy = new Dummy4j(); // Integer generation int randomInt = dummy.number().nextInt(); // Any integer int boundedInt = dummy.number().nextInt(100); // 0-99 int rangeInt = dummy.number().nextInt(5, 10); // 5-10 inclusive // Long generation long randomLong = dummy.number().nextLong(); // Any long long boundedLong = dummy.number().nextLong(1000000L); // 0-999999 long rangeLong = dummy.number().nextLong(100L, 500L); // 100-500 // Float generation float randomFloat = dummy.number().nextFloat(); // 0.0-1.0 float boundedFloat = dummy.number().nextFloat(100.0f); // 0.0-100.0 // Double generation double randomDouble = dummy.number().nextDouble(); // 0.0-1.0 // Boolean generation boolean trueOrFalse = dummy.nextBoolean(); // true or false System.out.println("Random int (5-10): " + rangeInt); System.out.println("Random float: " + randomFloat); System.out.println("Random boolean: " + trueOrFalse); ``` -------------------------------- ### Resolve Expressions with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Use the expression resolver to generate data from YAML keys or numeric patterns. ```java Dummy4j dummy = new Dummy4j(); // Resolve expressions from YAML definitions String maleAndFemale = dummy.expressionResolver() .resolve("#{name.male_first_name} and #{name.female_first_name}"); // Output: "John and Jane" // Numeric placeholders (# resolves to random digit 0-9) String phonePattern = dummy.expressionResolver().resolve("(###) ###-####"); // Output: "(555) 123-4567" // Nested expressions String resolved = dummy.expressionResolver() .resolve("#{address.city}, #{nation.country}"); // Output: "New York, United States" System.out.println("Names: " + maleAndFemale); System.out.println("Phone: " + phonePattern); ``` -------------------------------- ### Generate collections of locally unique values Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `dummy.unique().of(...)` to generate a collection where all elements are unique within that collection. ```java List tenUniqueNames = dummy.unique().of(() -> dummy.name().fullName(), name -> dummy.listOf(10, name)); System.out.println(tenUniqueNames); ``` -------------------------------- ### Advanced Component Injection Source: https://context7.com/daniel-frak/dummy4j/llms.txt Inject custom implementations of RandomService and ExpressionResolver for advanced control over data generation. ```java import dev.codesoapbox.dummy4j.*; import dev.codesoapbox.dummy4j.definitions.providers.files.yaml.YamlFileDefinitionProvider; // Create custom components RandomService randomService = new DefaultRandomService(123456L); YamlFileDefinitionProvider definitionProvider = YamlFileDefinitionProvider.withPaths( Arrays.asList("dummy4j", "my/custom/path")); ExpressionResolver expressionResolver = new DefaultExpressionResolver( Collections.singletonList("en"), randomService, definitionProvider); // Inject custom components Dummy4j dummy = new Dummy4j(expressionResolver, randomService); ``` -------------------------------- ### Select Random Elements with Dummy4j Source: https://context7.com/daniel-frak/dummy4j/llms.txt Randomly select elements from arrays, collections, varargs, or supplier functions using Dummy4j. It can also select random enum values. ```java Dummy4j dummy = new Dummy4j(); // From array String elementFromArray = dummy.oneOf(new String[]{"one", "two", "three"}); // From varargs String elementFromVarArgs = dummy.oneOf("apple", "banana", "cherry"); // From collection List options = Arrays.asList("red", "green", "blue"); String elementFromList = dummy.oneOf(options); // From suppliers (lazy evaluation) String nameOrCity = dummy.oneOf( () -> dummy.name().fullName(), () -> dummy.address().city() ); // Random enum value MyEnum randomEnum = dummy.nextEnum(MyEnum.class); System.out.println("Selected: " + elementFromArray); System.out.println("Name or City: " + nameOrCity); ``` -------------------------------- ### Run Mutation Tests for Committed Changes Source: https://github.com/daniel-frak/dummy4j/blob/master/CONTRIBUTING.md Execute mutation tests only for committed changes, excluding uncommitted work and changes already on the master branch. This is a faster way to test recent modifications. Ensure your Git repository is clean. ```shell mvn clean test-compile -Ppitest-config -Ppitest-pr -DoriginBranch=$(git rev-parse --abbrev-ref HEAD) ``` -------------------------------- ### Generate globally unique values Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `dummy.unique().value(...)` to generate values that are unique across the entire Dummy4j instance lifetime within a specified group. ```java for (int i = 0; i < 10; i++) { System.out.println( dummy.unique().value("fullNameGroup", () -> dummy.name().fullName()) ); } ``` -------------------------------- ### Generate locally unique values within a code block Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `dummy.unique().within(...)` to ensure values generated within a specific code block are unique to that block. ```java dummy.unique().within(() -> dummy.name().fullName(), name -> { for (int i = 0; i < 10; i++) { System.out.println(name.get()); } }); ``` -------------------------------- ### Select a random element from an array or collection Source: https://github.com/daniel-frak/dummy4j/blob/master/convenience-methods.md Use `oneOf(...)` to pick a random element from an array, collection, or an array of suppliers. ```java String elementFromArray = dummy.oneOf(new String[]{ "one", "two", "three" }); ``` ```java String elementFromCollection = dummy.oneOf(Arrays.asList("one", "two", "three")); ``` ```java String nameOrCity = dummy.oneOf(() -> dummy.name().fullName(), () -> dummy.address().city()); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.