Additional convenience methods as suggested by Sean Radford.

This commit is contained in:
Ben Alex 2004-09-11 06:13:54 +00:00
parent 03781aeccd
commit 8a32fde12a
2 changed files with 29 additions and 0 deletions

View File

@ -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();
}

View File

@ -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() {