Interface ICustomAttributeProviding

  • All Known Subinterfaces:
    ICustomAttributesEntity
    All Known Implementing Classes:
    ClientFormTheme, Mandant, Projekt, Textbaustein, Vorgang

    public interface ICustomAttributeProviding
    Interface for object that provide custom attributes, i.e. key-value pairs that can be used to store additional information. The stored data depends on the type of the object.
    Since:
    8.3.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • getCustomAttribute

        default String getCustomAttribute​(String key)
        Gets the value of the attribute with the given key.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, null if no such attribute exists.
      • getCustomAttributeAs

        default <T> T getCustomAttributeAs​(String key,
                                           Function<String,​? extends T> converter)
        Gets the value of the attribute with the given key.
        Type Parameters:
        T - Type of the attribute.
        Parameters:
        key - Name of the attribute.
        converter - Function to parse the string attribute value.
        Returns:
        The value of the attribute, null if no such attribute exists or the attribute value could not be converted to the desired type.
      • getCustomAttributeAs

        default <T> T getCustomAttributeAs​(String key,
                                           Function<String,​T> converter,
                                           T defaultValue)
        Gets the value of the attribute with the given key.
        Type Parameters:
        T - Type of the attribute.
        Parameters:
        key - Name of the attribute.
        converter - Function to parse the string attribute value.
        defaultValue - Default value to return if no value exists or the value could not be converted.
        Returns:
        The value of the attribute, or the default value if no such attribute exists or the attribute value could not be converted to the desired type.
      • getCustomAttributeBoolean

        default boolean getCustomAttributeBoolean​(String key)
        Gets the value of the attribute with the given key as a boolean.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, false if no such attribute exists.
      • getCustomAttributeDouble

        default double getCustomAttributeDouble​(String key)
        Gets the value of the attribute with the given key as a double.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or 0 if no such attribute exists or the attribute value could not be converted to a double.
      • getCustomAttributeDouble

        default double getCustomAttributeDouble​(String key,
                                                double defaultValue)
        Gets the value of the attribute with the given key as a double.
        Parameters:
        key - Name of the attribute.
        defaultValue - Default value to return if no value exists, or the value is not a valid double.
        Returns:
        The value of the attribute, or the default value if no such attribute exists or the attribute value could not be converted to a double.
      • getCustomAttributeEnum

        default <E extends Enum<E>> E getCustomAttributeEnum​(String key,
                                                             Class<E> enumType)
        Gets the value of the attribute with the given key as an enum constant.
        Type Parameters:
        E - Type of the enum.
        Parameters:
        key - Name of the attribute.
        enumType - Type of the enum.
        Returns:
        The value of the attribute, or 0 if no such attribute exists or the attribute value could not be converted to an enum constant.
      • getCustomAttributeEnum

        default <E extends Enum<E>> E getCustomAttributeEnum​(String key,
                                                             Class<E> enumType,
                                                             E defaultValue)
        Gets the value of the attribute with the given key as an enum constant.
        Type Parameters:
        E - Type of the enum.
        Parameters:
        key - Name of the attribute.
        enumType - Type of the enum.
        defaultValue - Default value to return if no value exists, or the value is not a valid enum constant.
        Returns:
        The value of the attribute, or the default value if no such attribute exists or the attribute value could not be converted to an enum constant.
      • getCustomAttributeInt

        default int getCustomAttributeInt​(String key)
        Gets the value of the attribute with the given key as an integer.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or 0 if no such attribute exists or the attribute value could not be converted to an integer.
      • getCustomAttributeInt

        default int getCustomAttributeInt​(String key,
                                          int defaultValue)
        Gets the value of the attribute with the given key as an integer.
        Parameters:
        key - Name of the attribute.
        defaultValue - Default value to return if no value exists, or the value is not a valid integer.
        Returns:
        The value of the attribute, or the default value if no such attribute exists or the attribute value could not be converted to an integer.
      • getCustomAttributeJsonArray

        default com.alibaba.fastjson.JSONArray getCustomAttributeJsonArray​(String key)
        Gets the value of the attribute with the given key as a JSON object.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or empty JSON object if no such attribute exists or the attribute value could not be parsed as a JSON object.
      • getCustomAttributeJsonObject

        default com.alibaba.fastjson.JSONObject getCustomAttributeJsonObject​(String key)
        Gets the value of the attribute with the given key as a JSON object.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or empty JSON object if no such attribute exists or the attribute value could not be parsed as a JSON object.
      • getCustomAttributeLong

        default long getCustomAttributeLong​(String key)
        Gets the value of the attribute with the given key as a long.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or 0 if no such attribute exists or the attribute value could not be converted to a long.
      • getCustomAttributeLong

        default long getCustomAttributeLong​(String key,
                                            long defaultValue)
        Gets the value of the attribute with the given key as a long.
        Parameters:
        key - Name of the attribute.
        defaultValue - Default value to return if no value exists, or the value is not a valid long.
        Returns:
        The value of the attribute, or the default value if no such attribute exists or the attribute value could not be converted to a long.
      • getCustomAttributeString

        default String getCustomAttributeString​(String key)
        Gets the value of the attribute with the given key as a string.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or empty string if no such attribute exists.
      • getCustomAttributeString

        default String getCustomAttributeString​(String key,
                                                String defaultValue)
        Gets the value of the attribute with the given key as a string.
        Parameters:
        key - Name of the attribute.
        defaultValue - Default value to return if no value exists.
        Returns:
        The value of the attribute, or the default value if no such attribute exists, or the attribute value is empty.
      • getCustomAttributeUuid

        default UUID getCustomAttributeUuid​(String key)
        Gets the value of the attribute with the given key as a UUID.
        Parameters:
        key - Name of the attribute.
        Returns:
        The value of the attribute, or null if no such attribute exists or the attribute value could not be parsed as a UUID.
      • getCustomAttributes

        Map<String,​String> getCustomAttributes()
        Gets the map of custom attributes that may be used to store additional information. The stored data depends on the type of the object.
        Returns:
        The custom attributes.