commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject [beanutils] DynaBean support for 'adders'
Date Fri, 14 Jun 2002 12:08:39 GMT
What do folks think about adding a new method to DynaBean called...

public interface DynaBean {
    public void add(String name, Object value);

This would allow you to use indexed properties without actually knowing what
the last index is. e.g. rather than

DynaBean db = ...;
db.set("foo", 0, a);
db.set("foo", 1, b);
db.set("foo", 2, c);

You could just do

db.add("foo", a);
db.add("foo", b);
db.add("foo", c);

It'd certainly make using indexed properties more 'Java 2 Collections like'.

Also its becoming quite common for developers to follow the 'adder' pattern.
Its like a getter, but adds one new item to a 'collection' of some kind.

public class MyBean {
    public Foo[] getFoos();
    public void addFoo(Foo foo);

It'd be nice if the DynaBean.add(String name, Object value) method could
automagically call the adder method for the given pseudo property for the

One downside with adding any new methods to DynaBean interface is that it'll
break backwards compatiblity. So we should introduce a DynaBeanSupport
classs that folks should be recommended to derive their custom
implementations from. If we did this then we could add other useful helper
methods like..

    public void populate(Map values);



Do You Yahoo!?
Get your free address at

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

View raw message