Open fprochazka opened 2 years ago
Could these be combined into a single PR? Maybe with a new option to avoid breaking existing code.
@Randgalt I've created two issues because I expected others to have a different opinion and you might be willing to accept only one part of the proposal, but both of the issues are related in my mind.
Hi, awesome library! Love it! I just have a small suggestion...
If I have a record with any collection
null
CostsBuilder.builder().build().extraData()
builds instance ofCosts
that hasextraData
initialized with emptyMap.of()
and does not returnnull
CostsBuilder.builder().build().extraData().get("value")
will not throw NPECostsBuilder.builder().extraData()
returns the defaultnull
CostsBuilder.builder().extraData().get("value")
will throw NPEI'm proposing that since you're adding special handling of collections and always initializing them, they should also be initialized to empty collections when the empty builder is created, so that the second case will also not throw an NPE