I am trying to use PropertyUtils class's copyProperties method to copy a bean.
The problem is that it fails to copy boolean if the getter of the boolean is written as "isXXX". It only works if the getter of the boolean is "getXXX". For example,
class MyBean {
....
public boolean isEnabled() {
return enabled;
}
....
}
PropertyUtils.copyProperties does not work for this class. But it works for this:
class MyBean {
....
public boolean getEnabled() {
return enabled;
}
....
}
Is there any way to fix this?
Many thanks
It depends on the enabled
type:
If it is boolean
, then the getter must be in this form:
public boolean isEnabled() {
return enabled;
}
If it Boolean
, then the getter must be in this form:
// The return type of the function doesn't matter Boolean or boolean
public Boolean getEnabled() {
return enabled;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With