[LIB-9] Some domain classes improvements
[chesshog.git] / chesshog-db-etude / src / main / java / org / hedgecode / chess / domain / DomainObject.java
index 923e4f5..4bef7a1 100644 (file)
@@ -21,8 +21,25 @@ package org.hedgecode.chess.domain;
  *
  * @author Dmitry Samoshin aka gotty
  */
-public abstract class DomainObject {
+public abstract class DomainObject<DomainObjectType extends DomainObject> {
 
-    public static final String ID_PROPERTY = "id";
+    public static final String ID_PARAMETER = "id";
+
+    public abstract Long getId();
+
+    public boolean isIdentical(DomainObjectType another) {
+        if (another == null)
+            return false;
+
+        if ((getId() == null) != (another.getId() == null))
+            return false;
+
+        if ((getId() == null) && (another.getId() == null))
+            return true;
+
+        return getId().equals(
+                another.getId()
+        );
+    }
 
 }