Package com.tccc.kos.commons.util
Interface ClientAttributeAware
public interface ClientAttributeAware
Interface that allows 3rd parties to attach attributes to a core
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.
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.
- Since:
- 1.8
- Version:
- 2025-08-01
-
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. -
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
-
setHiddenClientAttribute
Sets the attribute for the given name using an internal view that will prevent the value from being serialized to json.- Parameters:
name- the attribute namevalue- the attribute value
-
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
-
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
-
getClientAttributes
Return the attributes for json serialization. This has noJsonViewapplied, but this method can be overridden to apply a custom view if needed.
-