Package com.norconex.commons.lang.map
Enum Class PropertySetter
- All Implemented Interfaces:
Serializable,Comparable<PropertySetter>,Constable
Convenient way of handling the different ways a value (or values) can
be set on a Properties instance.
The above is the recommended attribute for consuming classes to use in XML configuration.
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionInserts supplied value(s) at the end of an existing list of values associated with the supplied key.Only set supplied value(s) if the supplied key does not exist or if it does not have any values associated.Inserts supplied value(s) at the beginning of an existing list of values.Replaces all value(s) already existing for a matching key with the supplied one(s). -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(Properties properties, String key, Object value) Applies thePropertySetterstrategy on the supplied properties with the given key and value.static PropertySetterstatic PropertySetterfrom(String name, PropertySetter defaultSetter) static PropertySetterfromXML(Xml xml, PropertySetter defaultValue) static PropertySetterorAppend(PropertySetter setter) static PropertySetterorOptional(PropertySetter setter) static PropertySetterorPrepend(PropertySetter setter) static PropertySetterorReplace(PropertySetter setter) static voidtoXML(Xml xml, PropertySetter setter) static PropertySetterReturns the enum constant of this class with the specified name.static PropertySetter[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
APPEND
Inserts supplied value(s) at the end of an existing list of values associated with the supplied key. If there are no matching keys or the key has no associated value(s), the supplied value(s) are set like a normal list addition. -
PREPEND
Inserts supplied value(s) at the beginning of an existing list of values. If there are no matching keys or the key has no associated value(s), the supplied value(s) are set like a normal list addition. -
REPLACE
Replaces all value(s) already existing for a matching key with the supplied one(s). If there are no matching keys or the key has no associated value(s), the supplied value(s) are set like a normal list addition. -
OPTIONAL
Only set supplied value(s) if the supplied key does not exist or if it does not have any values associated.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
apply
Applies thePropertySetterstrategy on the supplied properties with the given key and value. Collection or array values are considered as such. Supplying anullproperties argument as no effect.- Parameters:
properties- the properties to possibly add a key/value tokey- the key on which we set valuevalue- the value to possibly set
-
from
-
from
-
orAppend
-
orOptional
-
orPrepend
-
orReplace
-
fromXML
-
toXML
-