equality based on the ids of the contents of SingleRouterConfig.
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / SingleRouterConfig.java
index 40cbcc5116234491680c7a9428f0d3e5201c7017..8eab34b708996198b73c4cbfd271462937ff1119 100644 (file)
@@ -22,7 +22,6 @@ import org.wamblee.xmlrouter.config.Filter;
 import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
-// TODO implement equality based on ids for the single routerconfig. 
 // TODO implement copying of routerconfig. 
 
 /**
@@ -33,6 +32,7 @@ import org.wamblee.xmlrouter.config.Transformation;
  */
 public class SingleRouterConfig implements ExtendedRouterConfig {
     private Id<RouterConfig> id;
+
     private ExtendedConfig<DocumentType> documentTypes;
     private ExtendedConfig<Transformation> transformations;
     private ExtendedConfig<Filter> filters;
@@ -88,4 +88,25 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
     public Config<Filter> filterConfig() {
         return filters;
     }
+
+    @Override
+    public boolean equals(Object aObj) {
+        if (aObj == null) {
+            return false;
+        }
+        if (!(aObj instanceof SingleRouterConfig)) {
+            return false;
+        }
+        SingleRouterConfig obj = (SingleRouterConfig) aObj;
+
+        return documentTypes.equals(obj.documentTypes) &&
+            transformations.equals(obj.transformations) &&
+            filters.equals(obj.filters);
+    }
+
+    @Override
+    public int hashCode() {
+        return documentTypes.hashCode() + transformations.hashCode() +
+            filters.hashCode();
+    }
 }