0 Replies Latest reply on Jun 22, 2008 7:58 AM by Moshe Elisha

    How to use org.richfaces.model.TreeNode with generics

    Moshe Elisha Newbie

      I can't implement TreeNode with generics because of the getChildren() method.

      I have the following class:

      public class SystemTreeNode implements TreeNode<Integer> {
      
       private Integer data;
       private Map<Object, SystemTreeNode> childrensMap;
      
       public Iterator<Map.Entry<Object, TreeNode<Integer>>> getChildren() {
       return childrensMap.entrySet().iterator();
       }
       .
       .
       .
      }
      


      And it does not compile with the following error:

      found : java.util.Iterator<java.util.Map.Entry<java.lang.Object,com.xeround.xms.ui.tree.SystemTreeNode>>
      required: java.util.Iterator<java.util.Map.Entry<java.lang.Object,org.richfaces.model.TreeNode<java.lang.Integer>>>

      I can change the childrensMap var to
      Map<Object, TreeNode<Integer>> childrensMap;
      


      but this is not good enough.

      How can this be done?