view src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/ChildMoveOperation.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.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.jungleError.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;
    }
}