忽略源的 Null 检查,同时使用多个源参数映射方法

Ignore Null check at source , while Mapping methods with several source parameters

团队,我有一个与 map struct 相关的用例。 PFB 我的界面

@Mappings({
    @Mapping(source = "source1.name", target = "name"),
    @Mapping(source = "source2.address", target = "address"),
    @Mapping(source = "source3.company", target = "company")
})
public SomeClass map(Source1 source1,Source2  source2,Source3 source3);

一切正常。但我的问题是下面的代码片段(,它是由 mapstruct 基于上面定义的接口

public SomeClass map(Source1 source1,Source2  source2,Source3 source3)(
        if ( source1== null && source2== null && source3== null ) {
            return null;
        }

我的问题是,如果 source2 和 source3 为 null,我不想 return null,而是我将从 source1 映射可用的详细信息并继续。我已经浏览了 mapstruct 文档,但不幸的是我找不到任何可能的解决方案。 对于上述用例,我们在 mapstruct 中是否有任何解决方案,或者我们是否需要编写自定义逻辑来处理上述情况。 非常感谢这里的任何指示,并提前致谢。

Here My issue is I dont want to return null in case if source2 and source3 is null and rather I will map the available details from source1 and proceed.

查看 MapStruct 生成的片段,生成了所询问的确切内容。

public SomeClass map(Source1 source1, Source2 source2, Source3 source3)(
    if ( source1 == null && source2 == null && source3 == null ) {
        return null;
    }

    // rest of mmapping
}

这意味着如果 source1 不是 null 并且 source2source3null 那么映射将不会 return null,但它将使用 source1 进行映射