[concurrency-interest] Collection.contains(E)

David Holmes dcholmes at optusnet.com.au
Tue Apr 17 02:00:51 EDT 2007

The inference from which is that it was a mistake for NullPointerException
and ClassCastException to be optionally allowed on such query methods.

Water under the bridge now of course ...


> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Martin
> Buchholz
> Sent: Tuesday, 17 April 2007 3:26 PM
> To: concurrency-interest at cs.oswego.edu
> Subject: [concurrency-interest] Collection.contains(E)
> Here is an argument for why you might want query operations
> like contains(E) to *not* throw when the query object would
> not be permitted as an element:
> contains(E) is used to build higher-level operations like
> removeAll and retainAll.
> if s is a set of students at a university, and
> if p is a set of professors at a university,
> then these sets need not be disjoint, and so
> s.removeAll(p)
> is an operation that makes sense, and should not be
> prohibited, even when *inserting* an element of the
> wrong type should be.
> So contains(E) should generally never throw exceptions
> based on the unsuitability of its argument.
> Martin
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list