Custom model class for every element.#616
Conversation
|
Ah okay, interesting. This is basically an implementation of the polymorphism support. This is actually something which has been discussed quite a lot. So far, we have always suggested implementing a class cluster by overriding the See: #229 (comment) That being said, it has been mentioned many times, so I do agree that we should consider it. Some important factors for me:
|
|
@billinghamj It looks good for me. Implementing a class cluster by overriding the So, class method is crucial to this issue. Another similar way to avoid allocating twice is wrapping the |
|
So is it seems a good idea to use the |
|
@billinghamj
I added a bit is this PR. |
|
@heistings |
|
@heistings @billinghamj |
|
@qdvictory It looks good for me. Overriding the |
In the same location, if there are multiple models, this method can be used to output the corresponding model.
Such as,
[{ "background": "#ff0000", "foreground": "#0000ff", "typeField": "picture" }, { "body": "#ff0000", "tire": "#0000ff", "typeField": "car" }]there is a list, it has many types. So you want convert to model, it's very inconvenient.
Now, you can create a super class and subclass like:
create model like before:
output: