Browse Source

Additional convenience methods as suggested by Sean Radford.

Ben Alex 21 years ago
parent
commit
8a32fde12a

+ 23 - 0
core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java

@@ -74,6 +74,19 @@ public class ConfigAttributeDefinition {
         this.configAttributes.add(newConfigAttribute);
     }
 
+    /**
+     * Indicates whether the specified <code>ConfigAttribute</code> is
+     * contained within this <code>ConfigAttributeDefinition</code>.
+     *
+     * @param configAttribute the attribute to locate
+     *
+     * @return <code>true</code> if the specified <code>ConfigAttribute</code>
+     *         is contained, <code>false</code> otherwise
+     */
+    public boolean contains(ConfigAttribute configAttribute) {
+        return configAttributes.contains(configAttribute);
+    }
+
     public boolean equals(Object obj) {
         if (obj instanceof ConfigAttributeDefinition) {
             ConfigAttributeDefinition test = (ConfigAttributeDefinition) obj;
@@ -102,6 +115,16 @@ public class ConfigAttributeDefinition {
         return false;
     }
 
+    /**
+     * Returns the number of <code>ConfigAttribute</code>s defined by this
+     * <code>ConfigAttributeDefinition</code>.
+     *
+     * @return the number of <code>ConfigAttribute</code>s contained
+     */
+    public int size() {
+        return configAttributes.size();
+    }
+
     public String toString() {
         return this.configAttributes.toString();
     }

+ 6 - 0
core/src/test/java/org/acegisecurity/ConfigAttributeEditorTests.java

@@ -64,6 +64,12 @@ public class ConfigAttributeEditorTests extends TestCase {
         }
 
         assertEquals(5, position);
+
+        assertEquals(5, result.size());
+
+        assertTrue(result.contains(new SecurityConfig("HELLO")));
+        assertTrue(result.contains(new SecurityConfig("TOMORROW")));
+        assertFalse(result.contains(new SecurityConfig("FOOBAR")));
     }
 
     public void testEmptyStringReturnsNull() {