Suppose field_type in SourceObject can be any type from this list A,B,C,D
SourceObjectA {
"field1" : "",
"field2" : "",
"field_type" : "A"
}
SourceObjectB {
"field1" : "",
"field2" : "",
"field_type" : "B"
}
I have to map these SourceObjects to MongoObjects
E.g. For SourceObject with field_type "A", MongoObjectA should be formed
For SourceObject with field_type "B", MongoObjectB should be formed
How can we do this mapping? (Annotation based, Dependency Injection or some other design pattern). Want to avoid using Factory pattern here due to large number of different objects, so looking for some suggestion except Factory pattern approach.
Aucun commentaire:
Enregistrer un commentaire