view src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkDeleteAttributeOperation.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.jungleError.Error;
import jp.ac.u_ryukyu.ie.cr.jungle.util.Either;
import org.msgpack.annotation.Message;

import java.nio.ByteBuffer;

@Message
public class NetworkDeleteAttributeOperation implements NodeOperation
{
	/* MessagePack cannot handle final.*/
	//private final String key;
	private String key;
	
	public NetworkDeleteAttributeOperation()
	{
		key = null;
	}
	
	public NetworkDeleteAttributeOperation(String _key)
	{
		key = _key;
	}
	
	@Override
	public Command getCommand()
	{
		return Command.DELETE_ATTRIBUTE;
	}
	
	@Override
	public Either<Error, TreeNode> invoke(TreeNode _target)
	{
		return _target.getAttributes().delete(key);
	}

	@Override
	public int getPosition()
	{
		return -1;
	}

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

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