view src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkDeleteChildAtOperation.java @ 223:f0cc848b9af6

merge jungle-network but test faild
author tatsuki
date Tue, 15 Sep 2015 17:31:19 +0900
parents
children b3a04bc21b23
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.store.impl.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.Error;

import org.msgpack.annotation.Message;

import java.nio.ByteBuffer;

@Message
public class NetworkDeleteChildAtOperation implements NodeOperation
{
	/* MessagePack cannot handle final.*/
	//private final int pos;
	private int pos;
	
	
	public NetworkDeleteChildAtOperation() {}

	/* Position -1 represent root position. */	
	public NetworkDeleteChildAtOperation(int _pos)
	{
		pos = _pos;
	}
	
	@Override
	public Command getCommand()
	{
		return Command.DELETE_CHILD;
	}
	
	@Override
	public Either<Error, TreeNode> invoke(TreeNode _target)
	{
		return _target.getChildren().deleteChildAt(pos);
	}

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

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

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