foam-framework / foam2

FOAM: Feature-Oriented Active Modeller, Version 2
Apache License 2.0
73 stars 63 forks source link

No warning or assertion if I create a model with no ID and try to put it into a DAO #217

Open adamvy-google opened 7 years ago

adamvy-google commented 7 years ago

Instead I get null pointer exceptions from MDAO when it tries to convert the ID property to an index.

Not sure where the correct place is to put this validation, maybe the ClassProperty for all DAO.of should validate that OF has IDSupport of some sort.

jacksonic commented 7 years ago

The current flow has MDAO initialize its id index on creation ('of' is a required property), so it could be validated as soon as you try and create the MDAO.

Otherwise changing the init to be lazier could be an option.

jacksonic commented 7 years ago

Also I agree it's a general DAO requirement, since any DAO doing id comparisons should be using the efficient ID.compare() provided by IDSupport, so having a real ID property is required (rather than trying to cheat by assuming any 'obj.id' is good enough).