I am using POJO to create and fetch data. These POJOs represent our APIs and we use them for testing through REST Assured.
I have a RequestDTO
class with 30 variables. Since this is a DTO, I am using 30 setter methods in my class for updating there values.
I am calling these setter methods as below with method chaining. I am using varList
variable to read data from csv and supply to this DTO.
However this looks clumsy, less readable & incorrect. I want to know what is a good approach/design pattern here. As I have fairly less knowledge around best practices & design pattern.
Sample code:
public static void setRequestDTO(List<Object> varList) {
MyRequestDTO myrequest = new MyRequestDTO()
.setkey1(varList.get(0).toString())
.setkey2(varList.get(1).toString())
// ........
.setkey30(varList.get(30).toString());
}