title: Refactoring using Java 8
body: <p>I want to refactor my code by using Java 8, so I thought instead of using a setter method like this:</p>
  
  <pre><code>    Class MyService{
      User user = new User();
      user.setName(response.getName());
      user.setId(response.getId());
      user.setType(response.getType());
      user.setDesignation(response.getDesignation());
  }
  </code></pre>
  
  <p>in  my Service Class.</p>
  
  <p>I made a method in my User Pojo</p>
  
  <pre><code>Class User{
  
      public static User create(Response response){
      User user = new User();
      user.setName(response.getName());
      user.setId(response.getId());
      user.setType(response.getType());
      user.setDesignation(response.getDesignation());
      return user;
      }
  }
  </code></pre>
  
  <p>and in my service class, I wrote:</p>
  
  <pre><code>List&lt;User&gt; userList=reponseList.stream().map(User::create).collect(toList());
  </code></pre>
  
  <p>Is it a right way or any better solution other than this? I actually have a lot of setter methods in my service.</p>