view src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/ChildMoveOperation.java @ 265:b3a04bc21b23 Implementation_of_communication

add UnDefineNode
author tatsuki
date Tue, 13 Dec 2016 03:16:12 +0900
parents 803ab4479b7e
children c62462c28807
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.jungle.store.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.util.Either;
import jp.ac.u_ryukyu.ie.cr.jungle.util.Error;

import java.nio.ByteBuffer;

public class ChildMoveOperation implements NodeOperation
{
    private final int pos;
    private final String move; //上下どっちに移動するか 現状getKeyで取得可能

    public ChildMoveOperation(String move, int pos)
    {
        this.move = move;
        this.pos = pos;
    }

    @Override
    public Command getCommand()
    {
        return Command.MOVE_CHILD;
    }

    @Override
    public Either<Error, TreeNode> invoke(TreeNode _target)
    {
        return _target.getChildren().moveChild(pos,move);
    }

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

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

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