KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > EqualsEqualityComparator


1 /**
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.util;
5
6
7 /**
8  * An {@link EqualityComparator} that compares objects with {@link Object#equals(Object)}.
9  */

10 public class EqualsEqualityComparator implements EqualityComparator {
11   
12   public static final EqualsEqualityComparator INSTANCE = new EqualsEqualityComparator();
13   
14   private EqualsEqualityComparator() {
15     // Use INSTANCE instead.
16
}
17
18   public boolean isEquals(Object JavaDoc one, Object JavaDoc two) {
19     if ((one == null) != (two == null)) return false;
20     if (one == null) return true;
21     
22     return one.equals(two);
23   }
24
25 }
26
Popular Tags