java.lang.Object
com.aoapps.lang.attribute.Attribute<C,T>
An attribute has scope, context, and name and is used for value access.
- Author:
- AO Industries, Inc.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A name without any specific scope or context.static class
A backup value from before attribute initialization, which must beclosed
to restore the old value. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Attribute.Name
<T> Attribute
: Uses the given name, still needs scope or context.compute
(BiFunctionE<? super String, ? super T, ? extends T, ? extends Ex> remappingFunction) Much likeMap.compute(java.lang.Object, java.util.function.BiFunction)
, but for this attribute.computeIfAbsent
(FunctionE<? super String, ? extends T, ? extends Ex> mappingFunction) Much likeMap.computeIfAbsent(java.lang.Object, java.util.function.Function)
, but for this attribute.computeIfPresent
(BiFunctionE<? super String, ? super T, ? extends T, ? extends Ex> remappingFunction) Much likeMap.computeIfPresent(java.lang.Object, java.util.function.BiFunction)
, but for this attribute.abstract T
get()
Gets the value of this attribute.Gets the context for this attribute.getName()
Gets the attribute name.abstract T
getOrDefault
(T defaultValue) Much likeMap.getOrDefault(java.lang.Object, java.lang.Object)
, but for this attribute.abstract Attribute.OldValue
Initializes this attribute, returning a backup value, which must beclosed
to restore the old value.Much likeMap.merge(java.lang.Object, java.lang.Object, java.util.function.BiFunction)
, but for this attribute.abstract void
remove()
Removes the value from this attribute.abstract boolean
Much likeMap.remove(java.lang.Object, java.lang.Object)
, but for this attribute.abstract T
Much likeMap.replace(java.lang.Object, java.lang.Object)
, but for this attribute.abstract boolean
Much likeMap.replace(java.lang.Object, java.lang.Object, java.lang.Object)
, but for this attribute.abstract void
Sets the value of this attribute.abstract T
setIfAbsent
(T value) Much likeMap.putIfAbsent(java.lang.Object, java.lang.Object)
, but for this attribute.
-
Field Details
-
name
-
-
Constructor Details
-
Attribute
-
-
Method Details
-
getContext
Gets the context for this attribute.- Returns:
- the context or
null
when none
-
getName
Gets the attribute name. -
init
Initializes this attribute, returning a backup value, which must beclosed
to restore the old value. This is best used in try-with-resources. -
compute
public abstract <Ex extends Throwable> T compute(BiFunctionE<? super String, ? super T, throws Ex? extends T, ? extends Ex> remappingFunction) Much likeMap.compute(java.lang.Object, java.util.function.BiFunction)
, but for this attribute. Synchronizes on context to ensure atomic operation.- Throws:
Ex
- See Also:
-
computeIfAbsent
public abstract <Ex extends Throwable> T computeIfAbsent(FunctionE<? super String, ? extends T, throws Ex? extends Ex> mappingFunction) Much likeMap.computeIfAbsent(java.lang.Object, java.util.function.Function)
, but for this attribute. Synchronizes on context to ensure atomic operation.- Throws:
Ex
- See Also:
-
computeIfPresent
public abstract <Ex extends Throwable> T computeIfPresent(BiFunctionE<? super String, ? super T, throws Ex? extends T, ? extends Ex> remappingFunction) Much likeMap.computeIfPresent(java.lang.Object, java.util.function.BiFunction)
, but for this attribute. Synchronizes on context to ensure atomic operation.- Throws:
Ex
- See Also:
-
get
Gets the value of this attribute.- Returns:
getContext()
may benull
, which will returnnull
-
getOrDefault
Much likeMap.getOrDefault(java.lang.Object, java.lang.Object)
, but for this attribute.- Returns:
getContext()
may benull
, which will returndefaultValue
- See Also:
-
merge
public abstract <Ex extends Throwable> T merge(T value, BiFunctionE<? super T, ? super T, throws Ex? extends T, ? extends Ex> remappingFunction) Much likeMap.merge(java.lang.Object, java.lang.Object, java.util.function.BiFunction)
, but for this attribute. Synchronizes on context to ensure atomic operation.- Throws:
Ex
- See Also:
-
remove
public abstract void remove()Removes the value from this attribute.getContext()
may benull
, which will skip removal -
remove
Much likeMap.remove(java.lang.Object, java.lang.Object)
, but for this attribute. Synchronizes on context to ensure atomic operation.- See Also:
-
replace
Much likeMap.replace(java.lang.Object, java.lang.Object)
, but for this attribute. Synchronizes on context to ensure atomic operation.- See Also:
-
replace
Much likeMap.replace(java.lang.Object, java.lang.Object, java.lang.Object)
, but for this attribute. Synchronizes on context to ensure atomic operation.- See Also:
-
set
Sets the value of this attribute. -
setIfAbsent
Much likeMap.putIfAbsent(java.lang.Object, java.lang.Object)
, but for this attribute. Synchronizes on context to ensure atomic operation.- See Also:
-
attribute
Attribute
: Uses the given name, still needs scope or context.
-