这是我的普通承包商

public TreeContainer(Class<T> type, Object parentPID, List<Object> childrensPID) throws IllegalArgumentException {
    super(type);
    this.parentPID = parentPID;
    this.childrensPID = childrensPID;
}


这是我的豆子(用吸气剂塞特)

public class DirectoryBean implements Serializable {
      private long id;
      private String name;
      private DirectoryBean parent;
      private List<DirectoryBean> childrens;
}


我像这样创建一个新的树容器

TreeContainer<DirectoryBean> treeContainer = new TreeContainer<DirectoryBean>(DirectoryBean.class,"parent", "childrens" );


但是“儿童”参数是非法的,在这种情况下如何传递列表参数

最佳答案

您的构造函数期望这样

List<Object> childrensPID


但您传递的是字符串“ childrens”。
您可以通过将其放在列表中来解决它。

List<Object> childrens = new ArrayList<Object>();
childrens.add("childrens");
new TreeContainer<DirectoryBean>(DirectoryBean.class,"parent", childrens );

09-25 20:24