Interface ClientAttributeAware
- All Known Implementing Classes:
DelayFuture,FailedFuture,FutureWork,ParallelFuture,SequencedFuture,Trouble
ClientAttributeAware object in a way that allows the attribute
data to be serialize to json. This differs from AttributeAware
which is not compatible with json serialization and intended for java
access only. Some objects may be both ClientAttributeAware and
AttributeAware, where client attributes are exposed via endpoints
where non-client attributes are not.
This interface requires access to a Map to back the attributes.
The values in the map will always be wrapped in a JsonViewWrapper
object so the map should not be accessed directly. The interface will
return the original wrapped data for use in java, while returning the
wrapped view of the data for json serialization. This allows every object
placed into the map to have a custom json view applied, which avoids
the view of the ClientAttributeAware object from being applied
to the data in the attribute map.
There is support for adding attributes which will not be serialized
to json by using the setHiddenClientAttribute(String, Object)
method. This effectively allows ClientAttributeAware to be
used as AttributeAware which doesn't support json serialization.
- Since:
- 8
- Version:
- 8
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceJson view used for private attributes -
Method Summary
Modifier and TypeMethodDescriptionReturn theMapthat backs the attributes.default ObjectgetClientAttribute(String name) Given a name, return the associated attribute value.default Map<String,JsonViewWrapper> Return the attributes for json serialization.default ObjectremoveClientAttribute(String name) Remove the attribute with the specified name.default voidsetClientAttribute(String name, Object value, Class<?> view) Sets the attribute for the given name and specifies the view used to serialize the attribute to json.default voidsetHiddenClientAttribute(String name, Object value) Sets the attribute for the given name using an internal view that will prevent the value from being serialized to json.
-
Method Details
-
_getClientAttributeMap
Map<String,JsonViewWrapper> _getClientAttributeMap()Return theMapthat backs the attributes. This is used within theClientAttributeAwareinterface and should never be accessed directly.- Since:
- 8
-
setClientAttribute
Sets the attribute for the given name and specifies the view used to serialize the attribute to json.- Parameters:
name- the attribute namevalue- the attribute valueview- the json view used to serialize the value- Since:
- 8
-
setHiddenClientAttribute
Sets the attribute for the given name using an internal view that will prevent the value from being serialized to json. This allowsClientAttributeAwareto be used similar toAttributeAwarefor objects that only provideClientAttributeAwaresupport.- Parameters:
name- the attribute namevalue- the attribute value- Since:
- 8
-
getClientAttribute
Given a name, return the associated attribute value.- Parameters:
name- the attribute name- Returns:
- the value of the attribute, or
nullif it doesn't exist - Since:
- 8
-
removeClientAttribute
Remove the attribute with the specified name.- Parameters:
name- the attribute to remove- Returns:
- the value of the attribute being removed, or
nullif it didn't exist - Since:
- 8
-
getClientAttributes
Return the attributes for json serialization. This returns null if the map is empty in order to minimize payload sizes. This has no defaultJsonView. If a view is required, override the method and apply the correct view.The default json property name is
attrs.This should not be used to directly access or manipulate the attributes map.
- Since:
- 8
-