FastEasyMapping
FastEasyMapping copied to clipboard
FEMRelationship conditional FEMMapping
Hi! I have a question about ability of FastEasyMapping to map relationship with different inner classes. I.e. I have a Questionnaire and it has 'questions' relation, but each question can be QuestionOpen or QuestionSelection, I can designate which class is that by 'type' property. @dimazen How can I achieve that?
Hello, @pablucco It is kind of a dynamic mapping that can be found on RestKit. Unfortunately it is not implemented and therefore you won't be able to do so.
However I can take a look in the evening how much effort it'll take to implement it. It should be fairly simple to do.
@dimazen It would be so great! How are you planning to implement that? I mean will that cause architecture changes?
@pablucco hello there.I was digging into it and here are few thoughts:
- we need to dynamically evaluate what
mapping
for the given JSON. The best way is to use blocks. - it is useful to add dynamic
keyPath
evaluation as well.
Most rough solution looks like adding block to the FEMMapping
itself, that will evaluate given JSON and return FEMRelationship
with correct values. I'm not quite sure, but it looks a little bit ugly to me. What do you think?
I mean will that cause architecture changes?
I don't think so. Probably we'll have few more methods on FEMMapping
and some internal changes for FEMDeserializer
.