Class BeanMetadataAttributeAccessor

java.lang.Object
org.springframework.core.AttributeAccessorSupport
org.springframework.beans.BeanMetadataAttributeAccessor
All Implemented Interfaces:
Serializable, BeanMetadataElement, AttributeAccessor
Direct Known Subclasses:
AbstractBeanDefinition, AutowireCandidateQualifier, PropertyValue

public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport implements BeanMetadataElement
Extension of AttributeAccessorSupport, holding attributes as BeanMetadataAttribute objects in order to keep track of the definition source.
Since:
2.5
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • BeanMetadataAttributeAccessor

      public BeanMetadataAttributeAccessor()
  • Method Details

    • setSource

      public void setSource(@Nullable Object source)
      Set the configuration source Object for this metadata element.

      The exact type of the object will depend on the configuration mechanism used.

    • getSource

      public @Nullable Object getSource()
      Description copied from interface: BeanMetadataElement
      Return the configuration source Object for this metadata element (may be null).
      Specified by:
      getSource in interface BeanMetadataElement
    • addMetadataAttribute

      public void addMetadataAttribute(BeanMetadataAttribute attribute)
      Add the given BeanMetadataAttribute to this accessor's set of attributes.
      Parameters:
      attribute - the BeanMetadataAttribute object to register
    • getMetadataAttribute

      public @Nullable BeanMetadataAttribute getMetadataAttribute(String name)
      Look up the given BeanMetadataAttribute in this accessor's set of attributes.
      Parameters:
      name - the name of the attribute
      Returns:
      the corresponding BeanMetadataAttribute object, or null if no such attribute defined
    • setAttribute

      public void setAttribute(String name, @Nullable Object value)
      Description copied from interface: AttributeAccessor
      Set the attribute defined by name to the supplied value.

      If value is null, the attribute is removed.

      In general, users should take care to prevent overlaps with other metadata attributes by using fully-qualified names, perhaps using class or package names as prefix.

      Specified by:
      setAttribute in interface AttributeAccessor
      Overrides:
      setAttribute in class AttributeAccessorSupport
      Parameters:
      name - the unique attribute key
      value - the attribute value to be attached
    • getAttribute

      public @Nullable Object getAttribute(String name)
      Description copied from interface: AttributeAccessor
      Get the value of the attribute identified by name.

      Return null if the attribute doesn't exist.

      Specified by:
      getAttribute in interface AttributeAccessor
      Overrides:
      getAttribute in class AttributeAccessorSupport
      Parameters:
      name - the unique attribute key
      Returns:
      the current value of the attribute, if any
    • removeAttribute

      public @Nullable Object removeAttribute(String name)
      Description copied from interface: AttributeAccessor
      Remove the attribute identified by name and return its value.

      Return null if no attribute under name is found.

      Specified by:
      removeAttribute in interface AttributeAccessor
      Overrides:
      removeAttribute in class AttributeAccessorSupport
      Parameters:
      name - the unique attribute key
      Returns:
      the last value of the attribute, if any