Randgalt / record-builder

Record builder generator for Java records
Apache License 2.0
756 stars 55 forks source link

generate "add" method for collections #142

Closed maxandersen closed 1 year ago

maxandersen commented 1 year ago

given this:

record Rule(String name, Filter filter, List<Action>) {}

I would love I could do:

RuleBuilder.name("arule").filter(f().from("max@acme.org")).action(markAsSeen()).action(fileTo("folder")).build()

Basically, in addition to generating action(List<Action>) add a action(Action) that builds up the list.

Randgalt commented 1 year ago

Add this:

@RecordBuilder.Options(addSingleItemCollectionBuilders = true, useImmutableCollections = true)