From dadc6c661054310181de228dda79c0efd7ec87af Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Tue, 14 Jan 2020 22:16:06 +0100 Subject: [PATCH] extra readme --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ccec82..7feabe2 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,34 @@ This project was inspired by the FactoryGirl project that was later renamed Fact * https://en.wikipedia.org/wiki/Edie_Sedgwick * https://www.imdb.com/title/tt0432402 -* https://hn.algolia.com/?q=factorybot \ No newline at end of file +* https://hn.algolia.com/?q=factorybot + +*Usage:* +for a java bean like: +```java +class Person{ + String name; + int age; + + //rest omitted for brevity +} +``` +* Create a definition (template for creating instances) like so: +``` +Factory.define(Person.class, () -> new Person("John", 48)); +``` +* Create instances like so: +``` +Person person = Factory.build(Person.class) +``` + +* But the real _power_ of this lies in +``` +Person person = Factory.build(Person.class, p -> p.setAge(25)); +``` +This will result in an object +```json +{name: "John", age: 25} +``` + +Meaning the template can be customized later on