Class EqualityDelegateSupport


  • public class EqualityDelegateSupport
    extends java.lang.Object
    When the default equals() and hashCode() of a class needs to be overridden for any purpose. An EqualityDelegate can supply an alternate definition for these two methods. The following methods: safeEquals(Object, Object), safeHashCode(Object) should be used in place of the standard methods for equality checks and hash code generation. A specific use of this class provides alternative definitions for serialization purposes (check out: ReferenceTracker)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean containsKey​(java.lang.Class<?> key)  
      protected EqualityDelegate get​(java.lang.Class<?> key)  
      void registerEqualityDelegate​(java.lang.Class<?> key, EqualityDelegate<?> delegate)  
      boolean safeEquals​(java.lang.Object foo, java.lang.Object bar)
      equals that uses null-safe equality (null==null: true) and the delegates to the equalityDelegates if there is one registered for the argument class.
      int safeHashCode​(java.lang.Object foo)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EqualityDelegateSupport

        public EqualityDelegateSupport()
    • Method Detail

      • containsKey

        protected boolean containsKey​(java.lang.Class<?> key)
      • registerEqualityDelegate

        public void registerEqualityDelegate​(java.lang.Class<?> key,
                                             EqualityDelegate<?> delegate)
      • safeHashCode

        public int safeHashCode​(java.lang.Object foo)
      • safeEquals

        public boolean safeEquals​(java.lang.Object foo,
                                  java.lang.Object bar)
        equals that uses null-safe equality (null==null: true) and the delegates to the equalityDelegates if there is one registered for the argument class.