001/**
002 * Equal.java
003 * jCOLIBRI2 framework. 
004 * @author Juan A. Recio-Garc�a.
005 * GAIA - Group for Artificial Intelligence Applications
006 * http://gaia.fdi.ucm.es
007 * 28/10/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.method.retrieve.FilterBasedRetrieval.predicates;
010
011import es.ucm.fdi.gaia.jcolibri.exception.NoApplicableFilterPredicateException;
012
013/**
014 * Predicate that compares if the case object is equal to a fixed value.
015 * @author Juan A. Recio-Garcia
016 * @author Developed at University College Cork (Ireland) in collaboration with Derek Bridge.
017 * @version 1.0
018 * @see FilterBasedRetrievalMethod
019 * @see FilterConfig
020 */
021public class EqualTo implements FilterPredicate {
022
023    private Object fqo;
024
025    public EqualTo(Object fixedQueryObject) {
026            fqo = fixedQueryObject;
027    }
028    
029    public boolean compute(Object caseObject, Object queryObject) throws NoApplicableFilterPredicateException {
030                if ((caseObject == null) && (fqo==null))
031                        return true;
032                else if(caseObject == null)
033                        return false;
034                else if(fqo == null)
035                        return true;
036                else
037                        return caseObject.equals(fqo);
038    }
039
040}