001    package jcolibri.method.retrieve.NNretrieval.similarity.local;
002    
003    import jcolibri.method.retrieve.NNretrieval.similarity.LocalSimilarityFunction;
004    
005    
006    /**
007     * This function returns 1 if both individuals are equal, otherwise returns 0
008     */
009    public class Equal implements LocalSimilarityFunction {
010    
011            /**
012             * Applies the similarity function.
013             * 
014             * @param o1
015             *            Object.
016             * @param o2
017             *            Object.
018             * @return the result of apply the similarity function.
019             */
020        public double compute(Object o1, Object o2) throws jcolibri.exception.NoApplicableSimilarityFunctionException{
021            if ((o1 == null) || (o2 == null))
022                return 0;
023            return o1.equals(o2) ? 1 : 0;
024        }
025        
026        /** Applicable to any class */
027            public boolean isApplicable(Object o1, Object o2)
028            {
029                    return true;
030            }
031    }