我有树状的结构
class T {
properties:P
children:Seq[T]
}
Run Code Online (Sandbox Code Playgroud)
我希望将它转换为另一个树状结构,其中一些转换应用于属性,并且具有父节点的字段:
class TT {
properties:PP
parent:TT
children:Seq[TT]
}
Run Code Online (Sandbox Code Playgroud)
在功能风格中找不到这样做的方法.你能帮我吗?
特别是@ om-nom-nom难以想象应该做的工作的java代码:
public class Omnomnom {
static class P {
String value;
}
static class PP {
String value;
}
static class T {
P properties;
List<T> children;
}
static class TT {
PP properties;
TT parent;
List<TT> children;
}
static PP transform_P_into_PP(P properties) {
PP result = new PP();
result.value = properties.value + "pff";
return result;
}
public static TT transform_T_into_TT(T node, TT …Run Code Online (Sandbox Code Playgroud)