package at.oefai.aaa.agent.jam;

import java.io.Serializable;

import at.oefai.aaa.agent.jam.types.Binding;

/**
 * A built-in JAM primitive action for adding a goal to the JAM goal list.
 * @author Marc Huber
 * @author Jaeho Lee
 */
class UnpostAction extends AbstractAction implements Serializable {

    private final GoalAction goalAction;
    private final IntentionStructure intentionStructure;

    /**  */
    UnpostAction(final GoalAction pGoalAction, final IntentionStructure pIntentionStructure) {
        this.goalAction = pGoalAction;
        this.intentionStructure = pIntentionStructure;
    }

    // Member functions

    public boolean isExecutableAction() { return true; }

    /** Remove a goal from the agent. */
    public Result execute(final Binding b, final Goal currentGoal) {
        this.intentionStructure.drop(this.goalAction, b);
        return Result.SUCCEEDED;
    }

    /** Output information to the stream in an in-line manner. */
    public String formattedString(final Binding b) {
        return "Printing UNPOST.\n";
    }

    public String getName() {
        return "UNPOST";
    }
}

