接口 AttributeAccessor
- 所有已知子接口:
AnnotatedBeanDefinition
,BeanDefinition
,TestContext
- 所有已知实现类:
AbstractBeanDefinition
,AnnotatedGenericBeanDefinition
,AttributeAccessorSupport
,AutowireCandidateQualifier
,BeanMetadataAttributeAccessor
,ChildBeanDefinition
,DefaultTestContext
,GenericBeanDefinition
,PropertyValue
,RootBeanDefinition
,ScannedGenericBeanDefinition
public interface AttributeAccessor
Interface defining a generic contract for attaching and accessing metadata to/from arbitrary objects.- 从以下版本开始:
- 2.0
- 作者:
- Rob Harrop
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 String[]
attributeNames()
Return the names of all attributes.Object
getAttribute(String name)
Get the value of the attribute identified byname
.boolean
hasAttribute(String name)
Returntrue
if the attribute identified byname
exists.Object
removeAttribute(String name)
Remove the attribute identified byname
and return its value.void
setAttribute(String name, Object value)
Set the attribute defined byname
to the suppliedvalue
.
方法详细资料
setAttribute
void setAttribute(String name, @Nullable Object value)
Set the attribute defined byname
to the suppliedvalue
. Ifvalue
isnull
, the attribute isremoved
.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.
- 参数:
name
- the unique attribute keyvalue
- the attribute value to be attached
getAttribute
@Nullable Object getAttribute(String name)
Get the value of the attribute identified byname
. Returnnull
if the attribute doesn't exist.- 参数:
name
- the unique attribute key- 返回:
- the current value of the attribute, if any
removeAttribute
@Nullable Object removeAttribute(String name)
Remove the attribute identified byname
and return its value. Returnnull
if no attribute undername
is found.- 参数:
name
- the unique attribute key- 返回:
- the last value of the attribute, if any
hasAttribute
boolean hasAttribute(String name)
Returntrue
if the attribute identified byname
exists. Otherwise returnfalse
.- 参数:
name
- the unique attribute key
attributeNames
String[] attributeNames()
Return the names of all attributes.