Class Setting<TValue>

  • Type Parameters:
    TValue - Type of the setting's value.
    All Implemented Interfaces:
    Serializable

    @ValidSetting
    public final class Setting<TValue>
    extends Object
    implements Serializable
    Generic class for a setting - a level or placement that a knob or control is set to. A settings can be though of as a key-value pair. It consists of two parts: (a) a name for the property (the key) and (b) its current value.

    Furthermore, a settings contains additional metadata, such as whether it is a required setting and requires a value to be set.

    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Constructor Detail

      • Setting

        public Setting()
        Create a new setting with the default values (editable and deletable).
    • Method Detail

      • getLocalizedDescription

        public String getLocalizedDescription()
        Returns:
        A localized description explaining this setting in detail.
      • getLocalizedName

        public String getLocalizedName()
        Returns:
        The localized, human-readable name of the technical getName().
      • getName

        public String getName()
        Returns:
        A technical identifier that uniquely identifies this settings. It must be unique in the context this setting is used.
        See Also:
        getLocalizedName()
      • getValue

        public TValue getValue()
        Returns:
        The current value of this settings. May be null to indicate absence of a value.
        See Also:
        isRequired()
      • isDeletable

        public boolean isDeletable()
        Returns:
        Applicable when this setting is used as part of a list of settings. When true, this parameter can be deleted from the list. When false, this parameter must always be present in the list. (Although not necessary, it is strongly suggested that a setting that is not deletable be required.
      • isNameEditable

        public boolean isNameEditable()
        Returns:
        Whether the getName() may be edited by the user. false is usually used for fixed settings that are known to exist. true is usually used for unknown or free settings of which the user may enter any amount.
      • isRequired

        public boolean isRequired()
        Returns:
        Whether this settings is required, i.e. whether a getValue() must be set.
      • isValueEditable

        public boolean isValueEditable()
        Returns:
        Whether the value of this setting can be edited. Usually used for read-only properties.
      • setDeletable

        public void setDeletable​(boolean deletable)
        Parameters:
        deletable - Applicable when this setting is used as part of a list of settings. When true, this parameter can be deleted from the list. When false, this parameter must always be present in the list. (Although not necessary, it is strongly suggested that a setting that is not deletable be required.
      • setLocalizedDescription

        public void setLocalizedDescription​(String localizedDescription)
        Parameters:
        localizedDescription - A localized description explaining this setting in detail.
      • setLocalizedName

        public void setLocalizedName​(String localizedName)
        Parameters:
        localizedName - The localized, human-readable name of the technical getName().
      • setName

        public void setName​(String name)
        Parameters:
        name - The new name for this setting.
      • setNameEditable

        public void setNameEditable​(boolean nameEditable)
        Parameters:
        nameEditable - Whether the getName() may be edited by the user. false is usually used for fixed settings that are known to exist. true is usually used for unknown or free settings of which the user may enter any amount-
      • setRequired

        public void setRequired​(boolean required)
        Parameters:
        required - Whether this settings is required, i.e. whether a getValue() must be set.
      • setValue

        public void setValue​(TValue value)
        Parameters:
        value - The new value for this setting.
      • setValueEditable

        public void setValueEditable​(boolean valueEditable)
        Parameters:
        valueEditable - Whether the value of this setting can be edited. Usually used for read-only properties.
      • with

        public Setting.Builder<TValue> with()
        Returns:
        A builder with the same properties as this instance. Use this builder to create a new setting instance with one or more properties changed.
      • builder

        public static <TValue> Setting.Builder<TValue> builder()
        Type Parameters:
        TValue - Type of the setting's value.
        Returns:
        A new builder for configuring a setting.
      • customSetting

        public static <TValue> Setting<TValue> customSetting()
        Type Parameters:
        TValue - Type of the setting's value.
        Returns:
        A custom setting where the user can edit both the name and the value. It is marked as required, if the user does not wish to enter a value, they should delete the setting.
      • predefinedPassword

        public static <TValue> Setting<TValue> predefinedPassword​(String name,
                                                                  boolean required)
        Type Parameters:
        TValue - Type of the setting's value.
        Parameters:
        name - Name of the setting.
        required - Whether the setting is required.
        Returns:
        A setting for a password with a predefined name. It is not editable and cannot be deleted.
      • predefinedSetting

        public static <TValue> Setting<TValue> predefinedSetting​(String name,
                                                                 boolean required)
        Type Parameters:
        TValue - Type of the setting's value.
        Parameters:
        name - Name of the setting.
        required - Whether the setting is required.
        Returns:
        A setting with a predefined name. It is not editable and cannot be deleted.