Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有如下的源类层次结构
Class A { List<B> bs; } Class B { List<C> cs; } Class C { String n; }
新的目标类层次结构如下
Class A1 { List<C1> cs; } Class C1 { String n; }
如您所见,目标类层次结构正在跳过 bs。如何配置将对象中的属性复制到目标但在源中跳过对象本身
一种粗略的解决方案是预处理源并将 List<C> cs 复制到 A 类中的瞬态变量。预处理后源将如下所示
Class A { List<B> bs; transient List<C> cs; } Class B { List<C> cs; } Class C { String n; }