move compare method to AbstractBean
[jSite2.git] / src / net / pterodactylus / util / beans / AbstractBean.java
index df6f789..53fe690 100644 (file)
@@ -74,4 +74,20 @@ public abstract class AbstractBean {
 
        }
 
+       /**
+        * Compares the two objects and returns whether they are equal according to
+        * {@link Object#equals(Object)}. This method takes <code>null</code>
+        * into account as a valid value for an object.
+        * 
+        * @param first
+        *            The first object
+        * @param second
+        *            The second object
+        * @return <code>true</code> if the two objects are equal,
+        *         <code>false</code> otherwise
+        */
+       protected boolean equal(Object first, Object second) {
+               return ((first == null) && (second == null)) || ((first != null) && first.equals(second)) || ((second != null) && second.equals(first));
+       }
+
 }