You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
awesome library! Love it! I just have a small suggestion...
If I have a record with any collection
@MyRecordBuilder// with useImmutableCollections = true, interpretNotNulls = truepublic record Costs(
@NullableBigDecimalshipping,
Map<String, Object> extraData
) { }
the default values when the builder initializes for all fields is null
calling CostsBuilder.builder().build().extraData() builds instance of Costs that has extraData initialized with empty Map.of() and does not return null
which means CostsBuilder.builder().build().extraData().get("value")will not throw NPE
calling CostsBuilder.builder().extraData() returns the default null
which means CostsBuilder.builder().extraData().get("value")will throw NPE
I'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
The text was updated successfully, but these errors were encountered:
@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
The text was updated successfully, but these errors were encountered: