Link to home
Start Free TrialLog in
Avatar of S_B
S_B

asked on

jakarta Beanutils - exlude methods while copy

I'm using jakarta Beanutils(1.6) for copying values from one to another bean.
As the beanutils use reflections for copying the stuff every getter/setter(origin, destination) pair is called if existing.

An example to make i clearer:
Origin bean:
getStuff()
getDate()
getName()

Destination bean:
setStuff(xx)
setDate(xx)
setName(xx)

Beanutils calls getStuff and sets it on the destination bean via setStuff(xx) while invoking BeanUtils.copyProperties(java.lang.Object dest, java.lang.Object orig)
How do i configure beanutils to exclude some getters to get called, so that in the example above only setDate get's called??
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You can just call copyProperty for the properties you want
Avatar of S_B
S_B

ASKER

This is what i wanted to avoid as this is a huge bean with lots of properties.
I'm aware of this possibility, but i'm looking for a way to configure the beanutils to skip the designated getter. The way i would solve this would be like this:
Get all methods via beanutils and skip the getters not wanted while copying with copyProperty
But i'm looking for solution to configure this and not coding.
You'd have to override  BeanUtilsBean.copyProperties
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of S_B

ASKER

Yo. worked for me.
thx for the solution!

lg S.
No problem
:-)