aima.core.logic.fol.kb.data.ReducedLiteral Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
The newest version!
package aima.core.logic.fol.kb.data;
import aima.core.logic.fol.parsing.ast.AtomicSentence;
/**
* @see Reduced Literal
*
* @author Ciaran O'Reilly
*
*/
public class ReducedLiteral extends Literal {
private String strRep = null;
public ReducedLiteral(AtomicSentence atom) {
super(atom);
}
public ReducedLiteral(AtomicSentence atom, boolean negated) {
super(atom, negated);
}
@Override
public Literal newInstance(AtomicSentence atom) {
return new ReducedLiteral(atom, isNegativeLiteral());
}
@Override
public String toString() {
if (null == strRep) {
StringBuilder sb = new StringBuilder();
sb.append("[");
if (isNegativeLiteral()) {
sb.append("~");
}
sb.append(getAtomicSentence().toString());
sb.append("]");
strRep = sb.toString();
}
return strRep;
}
}