title: Copy specific fields by using BeanUtils.copyProperties?
body: <p><code>springframework.beans.BeanUtils</code> is very useful to copy objects, and I use the "ignoreProperties" option frequently. However, sometimes I want to copy only specific objects (basically, the opposite of "ignore Properties"). Does anyone know how can I do that? Any help will be appreciated.</p>
  
  <pre><code>import org.springframework.beans.BeanUtils;
  
  public class Sample {    
      public static void main(String[] args) {    
          DemoADto demoADto = new DemoADto();
          demoADto.setName("Name of Demo A");
          demoADto.setAddress("Address of Demo A");
  
          DemoBDto demoBDto = new DemoBDto();
  
          // This is "ignoreProperties" option
          // But I want to know how I can copy only name field by using BeanUtils or something.
          BeanUtils.copyProperties(demoADto, demoBDto, new String[] {"address"});
  
          System.out.println(demoBDto.getName());
          System.out.println(demoBDto.getAddress());    
      }    
  }
  
  public class DemoADto {    
      private String name;    
      private String address;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getAddress() {
          return address;
      }
  
      public void setAddress(String address) {
          this.address = address;
      }    
  }
  
  public class DemoBDto {    
      private String name;    
      private String address;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getAddress() {
          return address;
      }
  
      public void setAddress(String address) {
          this.address = address;
      }    
  }
  </code></pre>