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
  • Method Details

    • _getClientAttributeMap

      Map<String,JsonViewWrapper> _getClientAttributeMap()
      Return the Map that backs the attributes.
    • setClientAttribute

      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.
      Parameters:
      name - the attribute name
      value - the attribute value
      view - the json view used to serialize the value
    • setHiddenClientAttribute

      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.
      Parameters:
      name - the attribute name
      value - the attribute value
    • getClientAttribute

      default Object getClientAttribute(String name)
      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

      default Object removeClientAttribute(String name)
      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

      default Map<String,JsonViewWrapper> getClientAttributes()
      Return the attributes for json serialization. This has no JsonView applied, but this method can be overridden to apply a custom view if needed.