commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Reopened] (COLLECTIONS-352) AbstractCollectionDecorator is inconsistent with AbstractListDecorator. Uses private member variable instead of protected getter
Date Thu, 28 Feb 2013 20:05:20 GMT

     [ https://issues.apache.org/jira/browse/COLLECTIONS-352?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart reopened COLLECTIONS-352:
-----------------------------------------

    
> AbstractCollectionDecorator is inconsistent with AbstractListDecorator. Uses private
member variable instead of protected getter
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-352
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-352
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.0, 3.1, 3.2
>            Reporter: Adam Gent
>            Priority: Minor
>             Fix For: 4.0
>
>
> AbstractListDecorator uses getList() to access its private member variable for its methods:
> {code}
>     public int indexOf(Object object) {
>         return getList().indexOf(object);
>     }
> {code}
> Which allows me to almost do something like this (notice I'm taking some liberties here
with the no-arg serialization constructor):
> {code}
>     public static class FutureList<T> extends AbstractListDecorator {
>         private Future<List<T>> futureList;
>         public FutureList(Future<List<T>> futureList)
>         {
>             super();
>             this.futureList = futureList;
>         }
>         @Override
>         protected Collection<T> getCollection()
>         {
>             try
>             {
>                 return futureList.get();
>             }
>             catch (InterruptedException e)
>             {
>                 throw new RuntimeException(e);
>             }
>             catch (ExecutionException e)
>             {
>                 throw new RuntimeException(e);
>             }
>         }
>     }
> {code}
> But AbstractCollectionDecorator uses its private member variable
> {code}
>     public boolean add(Object object) {
>         return collection.add(object);
>     }
> {code}
> When it should be IMHO:
> {code}
>     public boolean add(Object object) {
>         return getCollection().add(object);
>     }
> {code}
> Of course most everybody has an armpit and an opinion :) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message