You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ms...@apache.org on 2011/03/12 21:01:10 UTC

svn commit: r1080993 - /myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/MoveChildComponentChange.java

Author: mstarets
Date: Sat Mar 12 20:01:09 2011
New Revision: 1080993

URL: http://svn.apache.org/viewvc?rev=1080993&view=rev
Log:
Modified hashCode() and equals() implementations to allow for null _insertBeforeId

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/MoveChildComponentChange.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/MoveChildComponentChange.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/MoveChildComponentChange.java?rev=1080993&r1=1080992&r2=1080993&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/MoveChildComponentChange.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/MoveChildComponentChange.java Sat Mar 12 20:01:09 2011
@@ -584,14 +584,18 @@ public final class MoveChildComponentCha
     
     return getSourceLogicalScopedId().equals(other.getSourceLogicalScopedId()) &&
            getDestinationLogicalScopedId().equals(other.getDestinationLogicalScopedId()) &&
-           _insertBeforeId.equals(other._insertBeforeId);
+           _equalsOrNull(_insertBeforeId, other._insertBeforeId);
   }
   
   @Override
   public int hashCode()
   {
-    return (getSourceLogicalScopedId().hashCode() + 37 * getDestinationLogicalScopedId().hashCode() +
-           1369 * _insertBeforeId.hashCode());
+    int hashCode = getSourceLogicalScopedId().hashCode() + 37 * getDestinationLogicalScopedId().hashCode();
+    if (_insertBeforeId != null)
+    {
+      hashCode = hashCode + 1369 * _insertBeforeId.hashCode();
+    }
+    return hashCode;
   }
       
   @Override
@@ -634,6 +638,11 @@ public final class MoveChildComponentCha
     return component;
   }
   
+  private boolean _equalsOrNull(Object obj1, Object obj2)
+  {
+    return (obj1 == null) ? (obj2 == null) : obj1.equals(obj2);
+  }
+  
   private transient UIComponent _commonParent;
 
   private final String _movableChildScopedId;