Просмотр исходного кода

Changed no-arg constructor to a form more suitable for unit testing. Also added an equals() method.

Ben Alex 21 лет назад
Родитель
Сommit
22b8be49f0
1 измененных файлов с 31 добавлено и 3 удалено
  1. 31 3
      core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java

+ 31 - 3
core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java

@@ -15,9 +15,9 @@
 
 package net.sf.acegisecurity;
 
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Set;
+import java.util.List;
+import java.util.Vector;
 
 
 /**
@@ -36,7 +36,7 @@ import java.util.Set;
 public class ConfigAttributeDefinition {
     //~ Instance fields ========================================================
 
-    private Set configAttributes = new HashSet();
+    private List configAttributes = new Vector();
 
     //~ Constructors ===========================================================
 
@@ -64,6 +64,34 @@ public class ConfigAttributeDefinition {
         this.configAttributes.add(newConfigAttribute);
     }
 
+    public boolean equals(Object obj) {
+        if (obj instanceof ConfigAttributeDefinition) {
+            ConfigAttributeDefinition test = (ConfigAttributeDefinition) obj;
+
+            List testAttrs = new Vector();
+            Iterator iter = test.getConfigAttributes();
+
+            while (iter.hasNext()) {
+                ConfigAttribute attr = (ConfigAttribute) iter.next();
+                testAttrs.add(attr);
+            }
+
+            if (this.configAttributes.size() != testAttrs.size()) {
+                return false;
+            }
+
+            for (int i = 0; i < this.configAttributes.size(); i++) {
+                if (!this.configAttributes.get(i).equals(testAttrs.get(i))) {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        return false;
+    }
+
     public String toString() {
         return this.configAttributes.toString();
     }