Enum Class PropertySetter

java.lang.Object
java.lang.Enum<PropertySetter>
com.norconex.commons.lang.map.PropertySetter
All Implemented Interfaces:
Serializable, Comparable<PropertySetter>, Constable

public enum PropertySetter extends Enum<PropertySetter>

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
  • Enum Constant Details

    • APPEND

      public static final PropertySetter 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

      public static final PropertySetter 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

      public static final PropertySetter 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

      public static final PropertySetter 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

      public static PropertySetter[] 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

      public static PropertySetter valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • apply

      public void apply(Properties properties, String key, Object value)
      Applies the PropertySetter strategy on the supplied properties with the given key and value. Collection or array values are considered as such. Supplying a null properties argument as no effect.
      Parameters:
      properties - the properties to possibly add a key/value to
      key - the key on which we set value
      value - the value to possibly set
    • from

      public static PropertySetter from(String name, PropertySetter defaultSetter)
    • from

      public static PropertySetter from(String name)
    • orAppend

      public static PropertySetter orAppend(PropertySetter setter)
    • orOptional

      public static PropertySetter orOptional(PropertySetter setter)
    • orPrepend

      public static PropertySetter orPrepend(PropertySetter setter)
    • orReplace

      public static PropertySetter orReplace(PropertySetter setter)
    • fromXML

      public static PropertySetter fromXML(Xml xml, PropertySetter defaultValue)
    • toXML

      public static void toXML(Xml xml, PropertySetter setter)