BeanUtils.copyProperties - how to copy the values to the custom bean reference in a collection
package A;
Class A{
String name;
List<ClassB> myList;
// getters and setters
}
package A;
Class B{
}
package C;
Class A{
Str开发者_开发百科ing name;
List<ClassB> myList;
// getters and setters
}
package C;
Class B{
}
c.ClassA c_ClassA = new c.ClassA();
a.ClassA a_ClassA = new a.ClassA();
BeanUtils.copyProperties(c_ClassA,a_ClassA);
a_ClassA.myList has reference to c.ClassB when the above copyProperties method is used.
Instead i'm looking for a method to copy the values from c_ClassA to a_ClassA so that a_ClassA.myList has the list of a.ClassB reference instead of c.ClassB reference.
Use the source, Luke.(Or the JavaDoc) It copies the properties and does not do any form of casting. But you could implement this behavior yourself.
I do not know of an actual implementation that does this for you, since this is not the intendet behavior.
精彩评论