Package com.kosdev.kos.commons.util
Interface AttributeAware
- All Known Subinterfaces:
HttpRequest,WebsocketConnection
- All Known Implementing Classes:
DelayFuture,FailedFuture,FutureWork,ParallelFuture,SequencedFuture,UdevDevice,WebsocketClient
public interface AttributeAware
Interface for objects that can accumulate additional data in the
form of attributes. For example, consider an
HttpReqeust
object where filters or interceptors may attach additional data to the request
that can then be consumed later on by handlers. Consider attributes as
public information riding with the AttributeAware object, almost
like dynamic properties. This allows code written by one developer to
pass data to code written by another developer via the AttributeAware
object.
AttributeAware data is not expected to be serialized to json as
it uses Object keys for maximum flexibility, but aren't compatible
with json encoding. Similarly, there is no way to restrict the json view
of the values. Consider using ClientAttributeAware for objects that need
to expose attributes via json serialization.
- Since:
- 1
- Version:
- 1
-
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(Object key) Given a key, returns its attribute.removeAttribute(Object key) Given a key, removes the attribute.voidsetAttribute(Object key, Object value) Sets the attribute for the given key.
-
Method Details
-
setAttribute
Sets the attribute for the given key.- Parameters:
key- the attribute keyvalue- the attribute value- Since:
- 1
-
getAttribute
Given a key, returns its attribute.- Parameters:
key- the attribute key- Returns:
- the value of the attribute, or
nullif it doesn't exist - Since:
- 1
-
removeAttribute
Given a key, removes the attribute.- Parameters:
key- the attribute key- Returns:
- the value of the attribute being removed, or
nullif it didn't exist - Since:
- 1
-