update 优化MapstructUtils空判断
Signed-off-by: 秋辞未寒 <545073804@qq.com>
This commit is contained in:
parent
b9f861685a
commit
bab860e1a0
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user