开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜