commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject PropertyUtils.copyProperties() and inherited classes
Date Tue, 23 Sep 2008 07:46:19 GMT
Hi @all,
as it seems, the PropertyUtils.copyProperties() as well as
BeanUtils.copyProperties() only do a copy on "class-level".
As I would like to reuse my copy-methods for an inherited
class-structure I would like to ask if there is also a chance to do a
"full"-object copy for inherited classes for all properties.
public class Class1 {
    private String attribute1;
public class Class2  extends Class1 {
    private String attribute2;
public class Business {
    public static copy(Class1 source, Class1 dest) {
        PropertyUtils.copyProperties(source, dest) 
If I call Business.copy() with 2 instances of Class1, attribute1 is
perfectly copied. But if I call the same method with 2 instances of
Class2, only attribute1 is copied although I would also like to copy
attribute2 as well. Any chance to do that?
Furthermore I realized that enumerations are not copied, too. Is there a
chance to copy the bean-instance including enumerations?
Thanks for your help

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message