Refactoring using Java 8 -
i want refactor code using java 8, thought instead of using setter method this: class myservice{ user user = new user(); user.setname(response.getname()); user.setid(response.getid()); user.settype(response.gettype()); user.setdesignation(response.getdesignation()); } in service class. i made method in user pojo 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; } } and in service class, wrote: list<user> userlist=reponselist.stream().map(user::create).collect(tolist()); is right way or better solution other this? have lot of setter methods in service. instead of creating static create method, define user constructor takes response , initializes that. class user{ public user(response response) { ...