1 11 12 package org.eclipse.jface.viewers; 13 14 import org.eclipse.jface.util.Util; 15 16 28 public class TreeNode { 29 30 36 private TreeNode[] children; 37 38 42 private TreeNode parent; 43 44 47 protected Object value; 48 49 55 public TreeNode(final Object value) { 56 this.value = value; 57 } 58 59 public boolean equals(final Object object) { 60 if (object instanceof TreeNode) { 61 return Util.equals(this.value, ((TreeNode) object).value); 62 } 63 64 return false; 65 } 66 67 74 public TreeNode[] getChildren() { 75 if (children != null && children.length == 0) { 76 return null; 77 } 78 return children; 79 } 80 81 87 public TreeNode getParent() { 88 return parent; 89 } 90 91 96 public Object getValue() { 97 return value; 98 } 99 100 107 public boolean hasChildren() { 108 return children != null && children.length > 0; 109 } 110 111 public int hashCode() { 112 return Util.hashCode(value); 113 } 114 115 122 public void setChildren(final TreeNode[] children) { 123 this.children = children; 124 } 125 126 132 public void setParent(final TreeNode parent) { 133 this.parent = parent; 134 } 135 } 136 | Popular Tags |