Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Retrieve model from differents keypart (but same content) #88
I want to retrieve different model instance with different keypart like that :
But when I do that I get always the same model instance cause JRebirth use a toString() to compare if a model already exist
I will obtain with my example something like that in the method hashCode from MultitonKey.class
So JRebirth think this is the same instance but it's not.
Currently, the aim of key parts object are to be an unique combination of object that will be merged with toString method to generate a unique hash code.
I understand that you use SimpleListProperty to handle the data you are binding into your model-view.
So why don't you use a JavaBean (with all javafx properties you want) that will return an unique string (managed by toString method) easy to read when viewed into a debugger and fast enough when managing hundred of instances ?
I have planned to let the option to generate a custom key per Component (Model, Command & Service), I will perform this change soon
Let me know if you have any thought
Using a Java Bean for a single property is a bit confusing.
It's not really logical that if I have two property with the same content, JRebirh return the same model instance, and if I have different content,JRebirth return different instance of the model.
I have added some confusion when I merged 2 concepts:
The Model Object is the JavaBean or the business object (could be a string) that will be rendered by the model.
The Key part is a set ob object that shall guarantee the uniqueness of the model.
Most of times these 2 concepts are equals:
But if you are designing a bubble animation with some BubbleModel, your model object could be only a Color (red, blue etc...) but your key part must add a value that guarantee uniqueness of the model (like a incremental integer)
So to let your key part unique you must something that guarantee uniqueness if you can have ionto your application 2 model with same model object.
Is it a bit more intelligible ?
To let the option to generate the key by using another method, an annotation can be used on top of KeyPart class or internal methods.
It allows to call one or several method to generate the unique key.
Then all key parts will be concatenated and transformed as a hash