From 8a32fde12aedfcc7b06e39a1c0eb620c737bda05 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Sat, 11 Sep 2004 06:13:54 +0000 Subject: [PATCH] Additional convenience methods as suggested by Sean Radford. --- .../ConfigAttributeDefinition.java | 23 +++++++++++++++++++ .../ConfigAttributeEditorTests.java | 6 +++++ 2 files changed, 29 insertions(+) diff --git a/core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java b/core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java index b733152e9b..f87b1f6db1 100644 --- a/core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java +++ b/core/src/main/java/org/acegisecurity/ConfigAttributeDefinition.java @@ -74,6 +74,19 @@ public class ConfigAttributeDefinition { this.configAttributes.add(newConfigAttribute); } + /** + * Indicates whether the specified ConfigAttribute is + * contained within this ConfigAttributeDefinition. + * + * @param configAttribute the attribute to locate + * + * @return true if the specified ConfigAttribute + * is contained, false 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 ConfigAttributes defined by this + * ConfigAttributeDefinition. + * + * @return the number of ConfigAttributes contained + */ + public int size() { + return configAttributes.size(); + } + public String toString() { return this.configAttributes.toString(); } diff --git a/core/src/test/java/org/acegisecurity/ConfigAttributeEditorTests.java b/core/src/test/java/org/acegisecurity/ConfigAttributeEditorTests.java index 4eae4fcf22..2502534f46 100644 --- a/core/src/test/java/org/acegisecurity/ConfigAttributeEditorTests.java +++ b/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() {