AttributeAccessor、AttributeAccessorSupport
AttributeAccessor
顶层接口,用于向任意对象附加元数据或从任意对象访问元数据
void setAttribute(String name, @Nullable Object value);
@Nullable
Object getAttribute(String name);
default <T> T computeAttribute(String name, Function<String, T> computeFunction); 默认实现:若name没有设置value,则触发computeFunction来得到value并setAttribute
@Nullable
Object removeAttribute(String name);
boolean hasAttribute(String name);
String[] attributeNames();
AttributeAccessorSupport
AttributeAccessor的实现,使用LinkedHashMap key=name,value=value作为容器
#setAttribute 若value!=null,设置kv;否则视为removeAttribute
#getAttribute 直接map.get
#computeAttribute 直接map.computeIfAbsent(内部规则:若name对应的value==null,则触发function.apply得到value并put(key, newValue) )返回value
#removeAttribute 直接map.remove
#has Attribute 直接map. containsKey
#attributeNames map. keySet转换为String[]