Package org.jivesoftware.util
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 aSystemProperty
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SystemProperty.Builder<T>
addListener(Consumer<T> listener)
SystemProperty<T>
build()
Validates the details of the SystemProperty, and generates one if it's valid.<C> SystemProperty<List<C>>
buildList(Class<C> listType)
<C> SystemProperty<Set<C>>
buildSet(Class<C> listType)
static <T> SystemProperty.Builder<T>
ofType(Class<T> clazz)
Start a new SystemProperty builder.SystemProperty.Builder<T>
setBaseClass(Class<?> baseClass)
This indicates which class configured values must inherit from.SystemProperty.Builder<T>
setChronoUnit(ChronoUnit chronoUnit)
If the type of the property is aDuration
this is used to indicate how the value is saved in the database.SystemProperty.Builder<T>
setDefaultValue(T defaultValue)
Sets the default value for the SystemProperty.SystemProperty.Builder<T>
setDynamic(boolean dynamic)
SystemProperty.Builder<T>
setEncrypted(boolean encrypted)
SystemProperty.Builder<T>
setKey(String key)
Sets the key for the SystemProperty.SystemProperty.Builder<T>
setMaxValue(T maxValue)
Sets the maximum value for the SystemProperty.SystemProperty.Builder<T>
setMinValue(T minValue)
Sets the minimum value for the SystemProperty.SystemProperty.Builder<T>
setPlugin(String plugin)
Sets the name of the plugin that is associated with this property.SystemProperty.Builder<T>
setSorted(boolean sorted)
-
-
-
Method Detail
-
ofType
public static <T> SystemProperty.Builder<T> ofType(Class<T> clazz)
Start a new SystemProperty builder. The following types of SystemProperty are supported:String
Integer
- for which a default value must be supplied usingsetDefaultValue(Object)
Long
- for which a default value must be suppliedBoolean
- for which a default value must be suppliedDuration
- for which aChronoUnit
must be specified, to indicate how the value will be saved, usingsetChronoUnit(ChronoUnit)
Instant
JID
Class
- for which a base class must be specified from which values must inherit, usingsetBaseClass(Class)
- any
Enum
- for which a default value must be supplied List
- for which a collection type must be specified, usingbuildList(Class)
Set
- for which a collection type must be specified, usingbuildSet(Class)
- 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:
setMinValue(Object)
,setMaxValue(Object)
-
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 aDuration
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 isChronoUnit.MINUTES
, or saved as "3600" if the ChronoUnit isChronoUnit.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)
-
-