title: How to merge two java objects into one?
body: <p>I have two java object instances and I want to merge their values into one instance. I need to pick which object instance takes precedence when both object instances contain a value for a field. I also do not want to override values with null values.</p>
  
  <p>Example:</p>
  
  <pre><code>MyClass source = new MyClass("source", 1, null);
  MyClass target = new MyClass("target", 2, "b");
  merge(source, target);
  // target now has values ("source", 1, "b")
  </code></pre>
  
  <p>I'm using Java 8 and Spring boot 1.4.1.</p>
  
  <p>Edit: It looks like I was not clear so I added more description. In addition, I already provided my own solution. The intent was to contribute this solution for when others have the same issue. I've found other threads on here asking the same or similar question, but they did not have a complete solution like I posted below.</p>