view src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java @ 157:f98f2704b154 untilIndex

minnerChange
author one
date Sun, 07 Dec 2014 18:43:32 +0900
parents 8a0aa8fc137c
children
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction;

import java.nio.ByteBuffer;

import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;

import fj.Ord;
import fj.data.List;
import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;

public class DefaultTreeNode implements TreeNode, Comparable<TreeNode> {
  // private final DefaultNode wrap;
  private List<TreeNode> children;
  private TreeMap<String, ByteBuffer> attrs;
  private OperationLog log;

  private static final List<TreeNode> NIL_LIST = List.nil();
  private static final TreeMap<String, ByteBuffer> NIL_MAP = TreeMap.empty(Ord.stringOrd);

  public DefaultTreeNode() {
    this(NIL_LIST, NIL_MAP);
  }

  public DefaultTreeNode(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) {
    attrs = _attrs;
    children = _children;
  }

  @Override
  public DefaultTreeNodeChildren getChildren() {
    return new DefaultTreeNodeChildren(children, attrs);
  }

  @Override
  public DefaultTreeNodeAttribute getAttributes() {
    return new DefaultTreeNodeAttribute(children, attrs, log);
  }

  @Override
  public DefaultTreeNode createNewNode() {
    return new DefaultTreeNode();
  }

  public DefaultTreeNode clone() {
    return new DefaultTreeNode(children, attrs);
  }

  @Override
  public int compareTo(TreeNode o) {
    return this.hashCode() - o.hashCode();

  }

}