InstructorYogesh Chawla Replied on 22/11/2018
You can create static or non static inner class for each and every request type and define specific functionality according to that very request type in that very inner class.
Static or Non static inner class can be decided based on the variables and methods involved whether they are going to be unique for each and every object or same for all objects. For this you need to check module 7 of our course.
Generics are majorly used when same functionality is going to be implemented for different data types or different wrapper classes or different custom classes involved but in your case, i think functionality is going to be different for different request types so this can't be used.
The functionality is more or less the same
but based on the type - the payload template, the end point and some other parameters are specific to that type.
I can do that using If condition i.e. If Requesttype = "Type1" then endpoint = "https://abc.com" and accounttemplate = type1Accounttemplate.flt and infotemplate = type1infortemplate etc
same for type2 and Type 3.
I am trying to eliminate the 'if' condition.
I was thinking thst I would create 3 Classes for each Type and have same name properties. So at runtime if I get Type1 then using reflection create an object of Type1 and in code I can get the properties( tmpalte, endpoint) related to Type 1. I am not sure how that can be achieved so wanted guidance.