Class SystemProperty.Builder<T>

java.lang.Object
org.jivesoftware.util.SystemProperty.Builder<T>
Type Parameters:
T - the type of system property to build
Enclosing class:
SystemProperty<T>

public static final class SystemProperty.Builder<T> extends Object
Used to build a SystemProperty
  • Method Details

    • ofType

      public static <T> SystemProperty.Builder<T> ofType(Class<T> clazz)
      Start a new SystemProperty builder. The following types of SystemProperty are supported:
      Type Parameters:
      T - the type of SystemProperty
      Parameters:
      clazz - The class of property being built
      Returns:
      A SystemProperty builder
    • setKey

      public SystemProperty.Builder<T> setKey(String key)
      Sets the key for the SystemProperty. Must be unique
      Parameters:
      key - the property key
      Returns:
      The current SystemProperty builder
    • setDefaultValue

      public SystemProperty.Builder<T> setDefaultValue(T defaultValue)
      Sets the default value for the SystemProperty. This value will be used if the property is not set, or falls outside the minimum/maximum values configured.
      Parameters:
      defaultValue - the default value for the property
      Returns:
      The current SystemProperty builder
      See Also:
    • setBaseClass

      public SystemProperty.Builder<T> setBaseClass(Class<?> baseClass)
      This indicates which class configured values must inherit from. It must be set (and can only be set) if the default value is a class.
      Parameters:
      baseClass - - the base class from which all configured values must inherit
      Returns:
      The current SystemProperty builder
    • setMinValue

      public SystemProperty.Builder<T> setMinValue(T minValue)
      Sets the minimum value for the SystemProperty. If the configured value is less than minimum value, the default value will be used instead.

      Important: If a minimum value is configured, the type of property being built must implement Comparable.

      Parameters:
      minValue - the minimum value for the property
      Returns:
      The current SystemProperty builder
    • setMaxValue

      public SystemProperty.Builder<T> setMaxValue(T maxValue)
      Sets the maximum value for the SystemProperty. If the configured value is more than maximum value, the default value will be used instead.

      Important: If a maximum value is configured, the type of property being built must implement Comparable.

      Parameters:
      maxValue - the maximum value for the property
      Returns:
      The current SystemProperty builder
    • setChronoUnit

      public SystemProperty.Builder<T> setChronoUnit(ChronoUnit chronoUnit)
      If the type of the property is a Duration this is used to indicate how the value is saved in the database. For an example a Duration of one hour will be saved as "60" if the ChronoUnit is ChronoUnit.MINUTES, or saved as "3600" if the ChronoUnit is ChronoUnit.SECONDS.

      Important: The ChronoUnit is required, and must be set, if the type of property is a Duration.

      Parameters:
      chronoUnit - the unit of time the Duration is saved to the database in
      Returns:
      The current SystemProperty builder
    • addListener

      public SystemProperty.Builder<T> addListener(Consumer<T> listener)
      Parameters:
      listener - the listener that will be called when the value of the property changes
      Returns:
      The current SystemProperty builder
    • setDynamic

      public SystemProperty.Builder<T> setDynamic(boolean dynamic)
      Parameters:
      dynamic - true if changes to this property take effect immediately, false if a restart is required.
      Returns:
      The current SystemProperty builder
    • setEncrypted

      public SystemProperty.Builder<T> setEncrypted(boolean encrypted)
      Parameters:
      encrypted - true if this property should be encrypted, false if can be stored in plain text. Defaults to plain text if not otherwise specified.
      Returns:
      The current SystemProperty builder
    • setSorted

      public SystemProperty.Builder<T> setSorted(boolean sorted)
      Parameters:
      sorted - true if this property is a list and should be sorted, false otherwise.
      Returns:
      The current SystemProperty builder
    • setPlugin

      public SystemProperty.Builder<T> setPlugin(String plugin)
      Sets the name of the plugin that is associated with this property. This is used on the Openfire System Properties admin interface to provide filtering capabilities. This will default to Openfire if not set.
      Parameters:
      plugin - the name of the plugin creating this property.
      Returns:
      The current SystemProperty builder
    • build

      public SystemProperty<T> build() throws IllegalArgumentException
      Validates the details of the SystemProperty, and generates one if it's valid.
      Returns:
      A SystemProperty object
      Throws:
      IllegalArgumentException - if incorrect arguments have been supplied to the builder
    • buildList

      public <C> SystemProperty<List<C>> buildList(Class<C> listType)
    • buildSet

      public <C> SystemProperty<Set<C>> buildSet(Class<C> listType)