org.springframework.core
abstract public class: AttributeAccessorSupport [javadoc |
source]
java.lang.Object
org.springframework.core.AttributeAccessorSupport
All Implemented Interfaces:
AttributeAccessor, Serializable
Direct Known Subclasses:
AnnotatedGenericBeanDefinition, BeanMetadataAttributeAccessor, PropertyValue, AbstractBeanDefinition, ChildBeanDefinition, ScannedGenericBeanDefinition, RootBeanDefinition, GenericBeanDefinition, AutowireCandidateQualifier
Support class for
AttributeAccessors , providing
a base implementation of all methods. To be extended by subclasses.
Serializable if subclasses and all attribute values are Serializable .
- author:
Rob - Harrop
- author:
Juergen - Hoeller
- since:
2.0 -
| Method from org.springframework.core.AttributeAccessorSupport Detail: |
public String[] attributeNames() {
Set attributeNames = this.attributes.keySet();
return (String[]) attributeNames.toArray(new String[attributeNames.size()]);
}
|
protected void copyAttributesFrom(AttributeAccessor source) {
Assert.notNull(source, "Source must not be null");
String[] attributeNames = source.attributeNames();
for (int i = 0; i < attributeNames.length; i++) {
String attributeName = attributeNames[i];
setAttribute(attributeName, source.getAttribute(attributeName));
}
}
Copy the attributes from the supplied AttributeAccessor to this accessor. |
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AttributeAccessorSupport)) {
return false;
}
AttributeAccessorSupport that = (AttributeAccessorSupport) other;
return this.attributes.equals(that.attributes);
}
|
public Object getAttribute(String name) {
Assert.notNull(name, "Name must not be null");
return this.attributes.get(name);
}
|
public boolean hasAttribute(String name) {
Assert.notNull(name, "Name must not be null");
return this.attributes.containsKey(name);
}
|
public int hashCode() {
return this.attributes.hashCode();
}
|
public Object removeAttribute(String name) {
Assert.notNull(name, "Name must not be null");
return this.attributes.remove(name);
}
|
public void setAttribute(String name,
Object value) {
Assert.notNull(name, "Name must not be null");
if (value != null) {
this.attributes.put(name, value);
}
else {
removeAttribute(name);
}
}
|