Attribute#getvalues()
Rod Widdowson
rdw at steadingsoftware.com
Thu Mar 28 05:56:18 EDT 2013
The javadoc for Attribute#getvalues() states:
* Gets the unordered, unmodifiable collection of values of the
attribute.
This way of thinking is reflected in the code which has a setValues() (as
opposed to V2 in which a common paradigm is
attribute.getValues().add("thing");
But the code actually returns a modified, guarded set (one in which nulls
cannot be added). Further if I change getValues to return an unmodifiable
set some tests fail - a quick review shows that it is the tests that break,
not the code they are testing (if you see what I mean).
I think that it's reasonable to assume that the code represents more recent
thought than the javadoc (its the nature of the beast). Nonetheless I
prefer the paradigm of returning unmodifiable set since it makes
rationalizing about thread safety easier, plus I hate the idea of reaching
into an object and dinking with its contents even when it is guarded set,
but other may differ.
If no one objects though, I'll make the change (plus tests) tomorrow. We
can always change it back.
Rod
More information about the dev
mailing list