Last active
May 17, 2023 13:44
-
-
Save TGITS/c34a59a6e1d6f1ad2fd776b2e85a45c4 to your computer and use it in GitHub Desktop.
Exemple de script JShell pour générer une séquence d'éléments factices de différents types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DEPS net.datafaker:datafaker:1.9.0 | |
/** | |
* Pour executer avec JBang : jbang SeveralSuppliersStreamExample.jsh | |
* <p> | |
* Pour exécuter sous JShell : | |
* jshell --class-path .;.\lib\datafaker-1.9.0.jar | |
* /open SeveralSuppliersStreamExample.jsh | |
*/ | |
import net.datafaker.Faker; | |
import java.util.stream.Stream; | |
Faker faker = new Faker(); | |
System.out.println("Printing some fake objects from several sources (minimum 5, maximum 10):"); | |
Stream<Object> fakeStringsFromSeveralSources = faker.<Object>stream().suppliers(() -> faker.number().numberBetween(10, 30), () -> faker.bothify("0A???_###")).minLen(5).maxLen(10).generate(); | |
fakeStringsFromSeveralSources.forEach(System.out::println); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment