No description
Find a file
Sander Hautvast 4219d62691 minor change
2020-01-14 22:21:51 +01:00
src extra javadoc 2020-01-14 22:05:33 +01:00
.gitignore first commit 2020-01-14 22:02:38 +01:00
pom.xml first commit 2020-01-14 22:02:38 +01:00
README.md minor change 2020-01-14 22:21:51 +01:00

This little project is called Edie after Edie Sedgwick who was one of the artists in Andy Warhols Factory. The film about her life is called Factory Girl (2006). This project was inspired by the FactoryGirl project that was later renamed FactoryBot.

Usage: for a java bean like:

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));
  • Then 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

{name: "John", age: 25}

Meaning the template can be customized later on

More features

  • Factory can also create more complex (nested) objects
  • random numbers
  • counters
  • etc see FactoryTests.java