commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Colebourne <>
Subject Re: [collections] collections.list.LazyList set method
Date Thu, 14 Jul 2005 23:15:41 GMT
Björn Eickvonder wrote:
> I use a LazyList within a bean to store indexed properties, having only a
> "getList()" and a "setList(list)" method. This works fine as long as I only
> set nested properties of the indexed property, i.e. setting something like
> list[0].attribute.
> But if I try to set the indexed property itself by e.g.
> "PropertyUtils.setProperty(bean, "list[0]", "val0")" out of the beanutils
> package I get an ArrayIndexOutOfBounds because in the end this call uses the
> set-method of the underlying list.
> So my suggestion would be to slightly extend the LazyList by overwriting the
> set-method (defined in List) in the following way
>     public Object set(int index, Object obj) {
>       if (index>=size()) get(index);
>       return super.set(index, obj);
>     }
> What do you think about this idea?

See GrowthList in SVN which grows on set() and add(). To achieve a list 
that grows on set(), add() and get() you must use both a Lazylist and a 
GrowthList together.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message