update 优化MapstructUtils空判断

Signed-off-by: 秋辞未寒 <545073804@qq.com>
This commit is contained in:
秋辞未寒 2025-01-06 03:35:13 +00:00 committed by Gitee
parent b9f861685a
commit bab860e1a0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -59,7 +59,7 @@ public class MapstructUtils {
* @return target
*/
public static <T, V> V convert(T source, V target) {
if (ObjectUtil.hasNull(source)) {
if (ObjectUtil.hasNull(source, target)) {
return null;
}
return CONVERTER.convert(source, target);
@ -74,7 +74,7 @@ public class MapstructUtils {
* @return target
*/
public static <T, V> V convert(T source, V target, Consumer<V> beanConsumer) {
if (ObjectUtil.hasNull(source)) {
if (ObjectUtil.hasNull(source, target)) {
return null;
}
return CONVERTER.convert(source, target, beanConsumer);
@ -88,7 +88,7 @@ public class MapstructUtils {
* @return targetType
*/
public static <T, V> List<V> convert(List<T> sourceList, Class<V> targetType) {
if (CollUtil.isEmpty(sourceList)) {
if (CollUtil.isEmpty(sourceList) || ObjectUtil.isNull(targetType)) {
return CollUtil.newArrayList();
}
return CONVERTER.convert(sourceList, targetType);
@ -103,7 +103,7 @@ public class MapstructUtils {
* @return targetType
*/
public static <T, V> List<V> convert(List<T> sourceList, Class<V> targetType, Consumer<V> beanConsumer) {
if (CollUtil.isEmpty(sourceList)) {
if (CollUtil.isEmpty(sourceList) || ObjectUtil.isNull(targetType)) {
return CollUtil.newArrayList();
}
return CONVERTER.convert(sourceList, targetType, beanConsumer);