package at.oefai.aaa.agent.jam;

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

/**
 * Predicates (expressions evaluable to true/false).
 * @author Marc Huber
 * @author Jaeho Lee
 */
abstract class Predicate extends AbstractExpression {

    private final String name;
    protected final Relation relation;

    /** Primary constructor. */
    Predicate(final String pName, final Relation pRelation) {
        this.name = pName;
        this.relation = pRelation;
    }

    /** Output information without consideration of being inline with other information. */
    public String verboseString(final Binding b) {
        String s = "";
        s += "Name: " + this.name;
        s += ",\tValue = ";
        s += (eval(b) != null ? "True" : "False") + "\n";
        return s;
    }

    /** Output information considering that it may be inline with other information. */
    public String formattedString(final Binding b) {
        String s = "";
        s += "(";
        s += this.name + " ";
        s += this.relation.formattedString(b);
        s += ")";
        return s;
    }

}

