Hello Chris

Le 30/03/13 00:35, Mattmann, Chris A (388J) a écrit :
(...snip...)
However DataQuality [1] have another property, "lineage", and ISO 19115
said that those two properties are mutually exclusive. If the "lineage"
property is set, what should getReports() returns?
How about Collections.unmodifiable{List|Map|etc}?

In this context, it would be Collections.empty{Set|List}. The point was that we could see a nuance between "no elements", and "elements can not exist here in current context". In the first case, users can add elements. In the second case, they can not. Returning a null value in the second case would be a way to differentiate them.

Returning Collections.empty{Set|List} means that it is not worth to distinguish those two possibilities, which is a perfectly valid decision for keeping the API simpler. Eventually, the exception thrown by Collection.add(...) could contains a message saying why elements can't be added.

Returning null make the job a little bit easier in some situations like XML marshalling, where empty XML element is not the same than no XML element. But this can be considered as an implementation details.

    Martin

Reply via email to