#4056 Extend JSpecify support for container mapping and @NonNull return types#4057
Open
filiphr wants to merge 1 commit into
Open
#4056 Extend JSpecify support for container mapping and @NonNull return types#4057filiphr wants to merge 1 commit into
filiphr wants to merge 1 commit into
Conversation
…null return types Follow-up to mapstruct#1243 closing the gaps reported in mapstruct#4056: * `@NonNull` source on collection-typed property mappings now skips the wrapping null guard around the collection construction (mirrors the existing non-collection rule in PropertyMapping). * Container mapping methods (Iterable, Map, Stream, arrays) now honor JSpecify on their source parameter: ContainerMappingMethod and MapMappingMethod route the source-parameter presence check through the JSpecify-aware PresenceCheckMethodResolver (same helper BeanMappingMethod already uses), and the corresponding FTL templates wrap the early-return block in <#if sourceParameterPresenceCheck??>. * `@NonNull` mapping-method return type now implies NullValueMappingStrategy.RETURN_DEFAULT semantics across bean, iterable, map and stream mapping methods, so generated code never violates a @nonnull return contract by emitting `return null`. All new behaviour is gated on JSpecify annotations being present and is fully suppressed by the existing `mapstruct.disableJSpecify` option.
26eb64a to
19c830d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #4056.
Extends the JSpecify support added in #4033:
@NonNullsource on collection-typed property mappings skips the wrapping null guardIterable,Map,Stream) honor JSpecify on their source parameter@NonNullmapping-method return type impliesNullValueMappingStrategy.RETURN_DEFAULTsemantics across bean, iterable, map and stream mapping methodsAll new behaviour is gated on JSpecify annotations and remains fully suppressed by
mapstruct.disableJSpecify.