view src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkAppendChildAtOperation.java @ 329:2a0cb1f0ba4e

rename Error package
author kono
date Sat, 08 Jul 2017 21:05:55 +0900
parents c62462c28807
children
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations;


import jp.ac.u_ryukyu.ie.cr.jungle.store.Command;
import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode;
import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation;
import jp.ac.u_ryukyu.ie.cr.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.jungle.util.jungleError.Error;
import org.msgpack.annotation.Message;

import java.nio.ByteBuffer;

@Message
public class NetworkAppendChildAtOperation implements NodeOperation {
	
	/* MessagePack cannot handle final.*/
	//	private final int pos;
	private int pos;
	
	/* Position -1 represent root position. */
	public NetworkAppendChildAtOperation() { pos = -2; }
	
	public NetworkAppendChildAtOperation(int _pos) {
		pos = _pos;
	}
	
	public Command getCommand()
	{
		return Command.APPEND_CHILD;
	}
	
	@Override
	public Either<Error,TreeNode> invoke(TreeNode _target)
	{
		return _target.getChildren().addNewChildAt(pos);
	}

	@Override
	public int getPosition()
	{
		return pos;
	}

	@Override
	public String getKey()
	{
		return null;
	}

	@Override
	public ByteBuffer getValue()
	{
		return null;
	}
}