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 interface
Json view used for private attributes -
Method Summary
Modifier and TypeMethodDescriptionReturn theMap
that backs the attributes.default Object
getClientAttribute
(String name) Given a name, return the associated attribute value.default Map<String,
JsonViewWrapper> Return the attributes for json serialization.default Object
removeClientAttribute
(String name) Remove the attribute with the specified name.default void
setClientAttribute
(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 void
setHiddenClientAttribute
(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 theMap
that 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
null
if 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
null
if it didn't exist
-
getClientAttributes
Return the attributes for json serialization. This has noJsonView
applied, but this method can be overridden to apply a custom view if needed.
-