0

This is my generic construtor

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

This is my bean (with getter setter)

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

I create a new Tree Container like this

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

But the "childrens" parameter is illegal, how can i pass the list params in this situation


How to iterate with two arrays

How to iterate in arrays using ruby?

array1 = [1,2,3]
array2 = ["Birthday", "Anniversary" , "Graduation"]
4

2 に答える 2

1

Probably would be sufficient to change it to ? extends Object. However, the purpose of using generics here is to limit the range of data types. You'd be better off doing something like:

? extends BeanBaseObject

于 2012-04-17T15:13:43.730 に答える
1

コンストラクターはこれを期待しています

List<Object> childrensPID

しかし、文字列「子供」を渡しています。リストに入れることで回避できます。

List<Object> childrens = new ArrayList<Object>();
childrens.add("childrens");
new TreeContainer<DirectoryBean>(DirectoryBean.class,"parent", childrens );
于 2012-04-17T15:16:25.110 に答える