001    package aima.basic.simplerule;
002    
003    import aima.basic.ObjectWithDynamicAttributes;
004    
005    /**
006     * Implementation of an EQUALity condition.
007     *
008     */
009    
010    /**
011     * @author Ciaran O'Reilly
012     * 
013     */
014    public class EQUALCondition extends Condition {
015            private Object key;
016    
017            private Object value;
018    
019            public EQUALCondition(Object aKey, Object aValue) {
020                    assert (null != aKey);
021                    assert (null != aValue);
022    
023                    key = aKey;
024                    value = aValue;
025            }
026    
027            @Override
028            public boolean evaluate(ObjectWithDynamicAttributes p) {
029                    return value.equals(p.getAttribute(key));
030            }
031    
032            @Override
033            public String toString() {
034                    StringBuffer sb = new StringBuffer();
035    
036                    return sb.append(key).append("==").append(value).toString();
037            }
038    }