title: How to map one object to the other object in java
body: <p>I am implementing a component where one component receive a message, it sends another message to Audit component so it can be audited. </p>
  
  <p>Audit handler has model called AuditObject, and my component has MessageObject. Here is the code:</p>
  
  <pre><code>public final class AuditObject {
      private final Long id;
      private final String studyUid;
      private final AuditPatient patient;
      ...
  }
  
  public final class MessageObject {
      private final Long id;
      private final String studyUid;
      private final PatientObject patient;
      private final String accessorName;
      ...
  }
  </code></pre>
  
  <p>AuditPatient and PatientObject have same variables. </p>
  
  <p>I am trying to send it through amqp connection via jms message. I already have MessageGateway. So my code will look like this on my side.</p>
  
  <pre><code>public void send(MessageObject messageObject) {
      //translate MessageObject to AuditObject
      messageGateway.send(auditObject, endpoint);
  }
  </code></pre>
  
  <p>What is the best way to translate(or map) MessageObject to AuditObject? Do I have to manually create each fields by assigning them? What is the best way to approach this problem?</p>