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
{{ message }}
Repository navigation
Strategy to check at runtime the null value with JSpecifiy #4105
We have field that are null at object creation but a never null right after.
Example the field Id or CreatedAt on an entity. The field are nullable but on the ReadDto these field are not null.
I would like to be able to check at runtime that the field is not null with Objects.requireNonNull(...). It could be a new strategy for the mapping.
It may be possible with something like that: @Mapping(target = "createdAt", nullValueCheckStrategy = NullValueCheckStrategy.AT_RUNTIME)
Before implementing it, I'd like to confirm the preferred API direction. I can investigate whether this should be a new NullValueCheckStrategy value, a separate null-value validation strategy, or an opt-in mapping option that generates Objects.requireNonNull.
Once the direction is confirmed, I'll add processor tests for nullable source to non-null JSpecify target mappings, verify nested and direct property mappings, and implement the smallest compatible change with documentation.
Activity
exijn commentedon Aug 20, 2026
Hi, I'd like to work on this issue.
Before implementing it, I'd like to confirm the preferred API direction. I can investigate whether this should be a new
NullValueCheckStrategyvalue, a separate null-value validation strategy, or an opt-in mapping option that generatesObjects.requireNonNull.Once the direction is confirmed, I'll add processor tests for nullable source to non-null JSpecify target mappings, verify nested and direct property mappings, and implement the smallest compatible change with documentation.