commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Feist (JIRA)" <>
Subject [jira] [Commented] (COLLECTIONS-276) *Utils classes should not be extensible or able to be instantiated.
Date Thu, 01 May 2014 10:36:14 GMT


Daniel Feist commented on COLLECTIONS-276:

While you points in your original proposal are valid, the use case that you have ignored is
where a Util* class is extended and additional static methods are added.  We do this with
most, to avoid having two different MapUtils classes, one with the commons methods and one
with ours.  See:

I propose these constructors be protected to avoid instantiation but allow extension.

> *Utils classes should not be extensible or able to be instantiated.
> -------------------------------------------------------------------
>                 Key: COLLECTIONS-276
>                 URL:
>             Project: Commons Collections
>          Issue Type: Improvement
>    Affects Versions: 3.2
>            Reporter: Stephen Kestle
>            Priority: Minor
> I don't see any good reason why this CollectionUtils (and others) isn't final with a
private constructor.  There are no non-static methods, and any extension of them is going
to have to call through to the super to avoid compiler warnings.
> e.g. will provoke the warning that "static methods should
be called directly" (on CollectionUtils).
> Which would mean
> MyCollectionUtils{
> public static Collection select(){
>     return;
> }
> Which really defeats the purpose.  In Java5, we have static imports now -  these provide
more benefit than previous extension did anyhow.

This message was sent by Atlassian JIRA

View raw message