接口 AttributeAccessor
- 所有已知实现类:
AttributeAccessorSupport
public interface AttributeAccessor
Interface defining a generic contract for attaching and accessing metadata
to/from arbitrary objects.
- 从以下版本开始:
- 2.1.7
- 作者:
- Rob Harrop, TODAY
2020-02-22 12:47
-
方法概要
修饰符和类型方法说明Return the names Iterator.voiddefault <T> TcomputeAttribute(String name, Function<String, T> computeFunction) Compute a new value for the attribute identified bynameif necessary and set the new value in thisAttributeAccessor.voidcopyAttributesFrom(AttributeAccessor source) getAttribute(String name) Get the value of the attribute identified byname.String[]Return the names of all attributes.Return attributes mapbooleanhasAttribute(String name) Returntrueif the attribute identified bynameexists.booleanReturnstrueif this map contains no key-value mappings.removeAttribute(String name) Remove the attribute identified bynameand return its value.voidsetAttribute(String name, Object value) Set the attribute defined bynameto the suppliedvalue.
-
方法详细资料
-
setAttribute
Set the attribute defined bynameto the suppliedvalue. Ifvalueisnull, 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
Get the value of the attribute identified byname. Returnnullif the attribute doesn't exist.- 参数:
name- the unique attribute key- 返回:
- the current value of the attribute, if any
-
removeAttribute
Remove the attribute identified bynameand return its value. Returnnullif no attribute undernameis found.- 参数:
name- the unique attribute key- 返回:
- the last value of the attribute, if any
-
hasAttribute
Returntrueif the attribute identified bynameexists. Otherwise returnfalse.- 参数:
name- the unique attribute key
-
getAttributeNames
String[] getAttributeNames()Return the names of all attributes. -
attributeNames
Return the names Iterator.- 从以下版本开始:
- 4.0
-
hasAttributes
boolean hasAttributes()Returnstrueif this map contains no key-value mappings.- 返回:
trueif this map contains no key-value mappings- 从以下版本开始:
- 4.0
-
getAttributes
Return attributes map- 返回:
- attributes map
- 从以下版本开始:
- 3.0
-
computeAttribute
Compute a new value for the attribute identified bynameif necessary and set the new value in thisAttributeAccessor.If a value for the attribute identified by
namealready exists in thisAttributeAccessor, the existing value will be returned without applying the supplied compute function.The default implementation of this method is not thread safe but can overridden by concrete implementations of this interface.
- 类型参数:
T- the type of the attribute value- 参数:
name- the unique attribute keycomputeFunction- a function that computes a new value for the attribute name; the function must not return anullvalue- 返回:
- the existing value or newly computed value for the named attribute
- 抛出:
IllegalStateException- If computeFunction returnsnull- 从以下版本开始:
- 3.0
- 另请参阅:
-
copyAttributesFrom
- 从以下版本开始:
- 3.0
-
clearAttributes
void clearAttributes()
-