/*
  * (non-Javadoc)
  *
  * @see
  * com.intel.stl.ui.monitor.tree.FastTreeUpater#compare(com.intel.stl.ui
  * .monitor.FVResourceNode, java.lang.Object)
  */
 @Override
 protected int compare(FVResourceNode node, Integer element) {
   String name1 = node.getName();
   FVResourceNode node2 = nodeMap.get(element);
   String name2 = node2 == null ? null : node2.getName();
   return TreeNodeFactory.comapreNodeName(name1, name2);
 }
  @Override
  public MutableTreeNode mutable() {
    /*
     * We are creating a mutable view of the data, which means that the version
     * is going to probably change -- and we need to make sure any unmodified
     * children retain it.
     *
     * The simplest thing to do is to just flush the amortized work and be done
     * with it.
     */
    final Collection<NormalizedNode<?, ?>> oldChildren = castData().getValue();

    // Use a proper sizing hint here, as the default size can suck for both extremely large and
    // extremely small
    // collections. For the large ones we end up rehashing the table, for small ones we end up using
    // more space
    // than necessary.
    final Map<PathArgument, TreeNode> children = allocateMap(oldChildren.size());
    for (NormalizedNode<?, ?> child : oldChildren) {
      PathArgument id = child.getIdentifier();
      children.put(id, TreeNodeFactory.createTreeNode(child, getVersion()));
    }

    return new Mutable(this, children);
  }
  @Override
  public Optional<TreeNode> getChild(final PathArgument key) {
    // We do not cache the instantiated node as it is dirt cheap
    final Optional<NormalizedNode<?, ?>> child = castData().getChild(key);
    if (child.isPresent()) {
      return Optional.of(TreeNodeFactory.createTreeNode(child.get(), getVersion()));
    }

    return Optional.absent();
  }
 /*
  * (non-Javadoc)
  *
  * @see com.intel.stl.ui.monitor.tree.TreeUpater#createNode(int)
  */
 @Override
 protected FVResourceNode createNode(Integer id) {
   NodeRecordBean bean = nodeMap.get(id);
   return bean == null ? new FVResourceNode("null", null, -1) : TreeNodeFactory.createNode(bean);
 }
Пример #5
0
 // calls the findChildren() method to polulate this tree-node's set of children, and returns them
 public TreeSet<TreeNode> extractChildren() {
   return factory.extractChildren(this);
 }