Package de.aristaflow.adept2.util
Interface Attributable
-
- All Known Implementing Classes:
AttributedInputStream,RereadableContent.RrcInputStream
public interface AttributableThis interface allows arbitrary objects to have additional attributes. This is similar toUserAttributeContainerbut allows for arbitrary values not just strings. Obviously, this interface is not directly for serialisable objects since the stored objects need not be serialisable.- See Also:
Map
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectcomputeIfAbsent(String name, Function<? super String,Object> compFunc)Computes the value of the attribute with the designated name if the attribute is not present yet and returns the value (or the current value if already present and not computed).booleancontains(String name)Gets whether thisAttributablecontains an attribute value for the designated attribute name.booleancontainsType(String name, Class<?> valueType)Gets whether thisAttributablecontains an attribute value for the designated attribute name of the designated type.Objectget(String name)Gets the value of the attribute with the designated name ornullif the attribute is not present or has anullvalue.ObjectputIfAbsent(String name, Object value)Puts an attribute with the designated name and value if the attribute is not present yet and returnsnullor the existing current value.Objectremove(String name)Removes the attribute with the designated name and returns its current (previous) value.Objectreplace(String name, Object newValue)Replaces the value of the attribute with the designated name if it has a value and returns its previous value.booleanreplace(String name, Object oldValue, Object newValue)Replaces the value of the attribute with the designated name if it has the designated value.
-
-
-
Method Detail
-
contains
boolean contains(String name)
Gets whether thisAttributablecontains an attribute value for the designated attribute name.- Parameters:
name- The name of the attribute for which an attribute value exists or not.- Returns:
- Whether this
Attributablecontains an attribute value for the designated attribute name.
-
containsType
boolean containsType(String name, Class<?> valueType)
Gets whether thisAttributablecontains an attribute value for the designated attribute name of the designated type.- Parameters:
name- The name of the attribute for which an attribute value exists or not.valueType- The type of the value of the attribute of the designated name.- Returns:
- Whether this
Attributablecontains an attribute value for the designated attribute name of the designate type.
-
get
Object get(String name)
Gets the value of the attribute with the designated name ornullif the attribute is not present or has anullvalue.- Parameters:
name- The name of the attribute for which to retrieve the value.- Returns:
- The value of the attribute with the designated name or
nullif the attribute is not present or has anullvalue.
-
putIfAbsent
Object putIfAbsent(String name, Object value)
Puts an attribute with the designated name and value if the attribute is not present yet and returnsnullor the existing current value.- Parameters:
name- The name of the attribute which make available.value- The value of the attribute which to make available.- Returns:
- The previous value (always
null) or the current value (in case putting is refused since the attribute is already present).
-
computeIfAbsent
Object computeIfAbsent(String name, Function<? super String,Object> compFunc)
Computes the value of the attribute with the designated name if the attribute is not present yet and returns the value (or the current value if already present and not computed).- Parameters:
name- The name of the attribute which make available.compFunc- The function computing the attribute value which to make available.- Returns:
- The previous value if already present (and therefore not computed) or the computed value.
-
remove
Object remove(String name)
Removes the attribute with the designated name and returns its current (previous) value.- Parameters:
name- The name of the attribute which to remove.- Returns:
- The value of the removed attribute.
-
replace
Object replace(String name, Object newValue)
Replaces the value of the attribute with the designated name if it has a value and returns its previous value. If the attribute does not have a value yet, it will not be added andnullwill be returned. Note thatnullwill also be returned when replacing the explicit attribute valuenull.- Parameters:
name- The name of the attribute which to replace.newValue- The value of the attribute with which to replace the existing value.- Returns:
- The replaced value of the attribute or
nullin case of an unknown attribute (and no replacement).
-
replace
boolean replace(String name, Object oldValue, Object newValue)
Replaces the value of the attribute with the designated name if it has the designated value. If the attribute does not have a value yet, it will not be added andfalsewill be returned.- Parameters:
name- The name of the attribute which to replace.oldValue- The old value of the attribute which to replace.newValue- The value of the attribute with which to replace the old value.- Returns:
- Whether the attribute value has been replaced.
-
-