Skip to content

9 Customize your Bots

Junior edited this page Jun 14, 2024 · 2 revisions

Customize your bots

All generated bots will inherits a abstract class net.jfaker.bot.AbstractBot who have 2 methods:

public abstract B build(): method used to generate a instance with random data

public List<B> build(final long size): method used to generate a java.util.List using a previous method

Now imagine who you need implements new behaviors in your bots. For example you want save your instances in your database, you want your bot return a json, this is possible, for do it make a follow steps:

1 - Create a class for extend a class net.jfaker.bot.AbstractBot and you create all methods you need to use, remeber to keep this class with a non args constructor, you need to pass by parameters what your class need (ex.: pass a repository, a instance of some class who will make a class serialization).

2- In your bot configuration, in annotation @AutoFakerBot enter with your created class qualified name in a property abstractBotQualifiedName.

3 - It's done, now your bot will be implement your custom class