package com.sharomank.notes.util;

import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.util.ReflectionUtils;

import static org.springframework.util.Assert.notNull;

public final class JavaBeanUtils {
    private JavaBeanUtils() {
    }

    public static void copyNotNullProperties(Object source, Object target) {
        notNull(source);
        notNull(target);
        final BeanWrapper src = new BeanWrapperImpl(source);
        final BeanWrapper trg = new BeanWrapperImpl(target);
        ReflectionUtils.doWithFields(source.getClass(), field -> {
            String propName = field.getName();
            Object srcPropValue = src.getPropertyValue(propName);
            if (srcPropValue != null) {
                trg.setPropertyValue(propName, srcPropValue);
            }
        });
    }
}
@@ -178,64 +178,8 @@
 s;%0A%0A
-import static org.springframework.util.Assert.notNull;%0A%0A
 publ
@@ -291,16 +291,22 @@
 perties(
+final 
 Object s
@@ -311,16 +311,22 @@
  source,
+ final
  Object 
@@ -347,50 +347,52 @@
     
-notNull(source);%0A        notNull(target);%0A
+if (source != null && target != null) %7B%0A    
     
@@ -448,32 +448,36 @@
 ource);%0A        
+    
 final BeanWrappe
@@ -521,16 +521,20 @@
         
+  
+  
 Reflecti
@@ -584,16 +584,20 @@
 ld -%3E %7B%0A
+    
         
@@ -647,16 +647,20 @@
         
+    
 Object s
@@ -713,24 +713,28 @@
             
+  
+  
 if (srcPropV
@@ -741,32 +741,36 @@
 alue != null) %7B%0A
+    
                 
@@ -827,18 +827,26 @@
         
-%7D%0A
+    %7D%0A    
         
@@ -849,15 +849,25 @@
     %7D);%0A
+        %7D%0A
     %7D%0A%7D

fix for coverity-scan