changeset 6960:7aa5ac17d728

Implement ManagedFacet.isSame to determine whether two facets are the same.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 03 Sep 2013 21:50:23 +0200
parents c80671932461
children 6bc333c162d1
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/ManagedFacet.java
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/ManagedFacet.java	Tue Sep 03 21:49:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/ManagedFacet.java	Tue Sep 03 21:50:23 2013 +0200
@@ -16,7 +16,7 @@
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifacts.ArtifactNamespaceContext;
 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
-
+import org.dive4elements.river.utils.CompareUtil;
 
 /**
  * Facet with user-supplied theme-control-information (pos in list,
@@ -140,5 +140,24 @@
             return 0;
         }
     }
+
+    /**
+     * Returns true if the other is likely the same facet.
+     * This happens if a facet is defined for two outs.
+     */
+    public boolean isSame(Object other) {
+        if (!(other instanceof ManagedFacet)) {
+            return false;
+        }
+        ManagedFacet otherFacet = (ManagedFacet) other;
+        return  this.getVisible() == otherFacet.getVisible() &&
+                this.getActive() == otherFacet.getActive() &&
+                CompareUtil.areSame(this.getArtifact(), otherFacet.getArtifact()) &&
+                this.getIndex() == otherFacet.getIndex() &&
+                CompareUtil.areSame(this.getName(), otherFacet.getName()) &&
+                CompareUtil.areSame(this.getBoundToOut(), otherFacet.getBoundToOut()) &&
+                CompareUtil.areSame(this.getDescription(), otherFacet.getDescription());
+        // Missing properties are blackboard, data, position.
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org