Randgalt / record-builder

Record builder generator for Java records

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add emptyDefaultForCollections options

krzyk opened this issue · comments

I think many people would like to have emptyDefaultForCollections, where instead of nulls builder would set following instances in the record built:

  • List -> List.of()
  • Set -> Set.of()
  • Map -> Map.of()
  • Collection -> Set.of() or List.of()

Duplicate of #56

@Randgalt It doesn't look like a duplicate of #56.

My proposition is to handle null gracefully by using empty List/Set/Map, while #56 is all about umodifiable collections.

OK - I guess I misunderstood. You're staying if someone passes in a null to the builder then, e.g., List.of() is used instead of null? I'm not sure how I feel about that. I think that would be unexpected.