commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
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.
e.g.

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
WrapDynaBean.

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);


Thoughts?

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message