I have a requirement where some data is coming from client in json form where some of the fields will be null based on type.
Sample of data is
class Data{
String type;
Property1 prop1;
Property2 prop2;
Property3 prop3;
Property4 prop4;
List<Property5> prop5;
}
class Property5{
String a;
String b;
String c;
}
Here Data object is coming from client and based on type=type1 (prop2 will be null) for type=type2(prop1 will be null) for type=type3 (prop4 will be null)
I have to save this data in db based on type value data will be saved after different transformations.
How to design this in OOPS.Shall I use various switch,case or use subclasses based on type to handle DATA object.
Aucun commentaire:
Enregistrer un commentaire