Since 1.5.11 the atomcontainer properties collection returns unmodifiable map.
@Override public Map<Object, Object> getProperties() { return properties == null ? Collections.emptyMap() : Collections.unmodifiableMap(properties); }
I've probably missed when this change was discussed.
I can see the reason (and the inefficient workaround through cloning), but this change is likely to break a lot of code, e.g. in the simple scenario of reading the structure and properties form SDF file, calculating something and putting back into properties.
OK, there is setProperty() which should be used instead, still existing code needs to be modified.
For encapsulation the caller shouldn't have direct access to the underlying
array/collection. I understand existing code that makes than assumption
will break but the benefit is we can show an empty map without allocating
the maps. If we looped over an molecule with 20 atoms and called
getProperties() on each atom just to see if there were any this silently
allocates 1KB of arrays let alone the object overhead.
Regards,
John W May
john.wilkinsonmay@gmail.com
On 9 September 2015 at 07:39, Nina Jeliazkova vedina@users.sf.net wrote:
Related
Bugs:
#1372Thanks, this is fine, consider this closed.
Would you consider moving AMBIT to github Nina? I'd be more than happy to test and patch changes like this if it was easy.
Not impossible :)
On 9 September 2015 at 12:26, John May jwmay@users.sf.net wrote:
Related
Bugs:
#1372John, is there a replacement of mol.getProperties().clear() in 1.5.11 ?
Nope, but we should add a clearProperties() method.
mol.setProperties(new LinkedHashMap<>());
?
Regards,
John W May
john.wilkinsonmay@gmail.com
On 9 September 2015 at 14:17, Nina Jeliazkova vedina@users.sf.net wrote:
Related
Bugs:
#1372+1