Softwire Blog


Java: auto-generated POJO builders


6 April 2015, by

Any of you that have worked for a while with Java have undoubtedly come across code similar to this, usually in unit tests:

public SomeEntity createEntityWithFoo(String foo) {
    SomeEntity entity = new Entity();
    entity.setFoo(foo);
    return entity;
}

public SomeEntity createEntityWithFooAndBar(String foo, String bar) {
    SomeEntity entity = new Entity();
    entity.setFoo(foo);
    entity.setBar(bar);
    return entity;
}

(more…)