commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: [SANDBOX][BeanUtils2] Discussion about cloneBean(), copyProperties() and cast() on DefaultBeanAccessor
Date Sun, 12 Feb 2012 17:28:17 GMT
Hi Bene,

>
> public B cloneBean()
>    throws aLotOfExceptions ;-)
> {
>    @SuppressWarnings( "unchecked" )
>    B clone = (B) bean.getClass().newInstance();
>    DefaultBeanAccessor<B> cloneAccessor = new DefaultBeanAccessor<B>( clone
> );
>    cloneAccessor.populate( this.describe() );
>    return clone;
> }
>
> copyProperties() can be implemented likewise. Is that really all we have to
> do, or am I missing something? I've looked at BeanUtils1 and they are
> handling Maps a little differently by coping all entries. So I guess we have
> to do the same (to keep the user experience).
>

did you already check older BeanUtils?

> Another thing I was winking about is cast(). I don't understand how that is
> supposed to work. Can it be, that there is an input parameter missing? To
> make it work it has to be:
>
> public <V> V cast(Class<V> targetType);
>

no, it doesn't "has to be", even if a little weird it doesn't require
the Class type. Have a look at[1] a give a try please with current
codebase ;)

Alles gute,
-Simo

[1] http://stackoverflow.com/questions/338887/java-generics-generic-type-defined-as-return-type-only

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/

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


Mime
View raw message