Enum PropertySetter

  • All Implemented Interfaces:
    Serializable, Comparable<PropertySetter>

    public enum PropertySetter
    extends Enum<PropertySetter>

    Convenient way of handling the different ways a value (or values) can be set on a Properties instance.

    XML configuration usage:

    
    onSet="[append|prepend|replace|optional]"

    The above is the recommended attribute for consuming classes to use in XML configuration.

    Since:
    2.0.0
    Author:
    Pascal Essiembre
    • Enum Constant Detail

      • 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 Detail

      • values

        public static PropertySetter[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PropertySetter c : PropertySetter.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PropertySetter valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type 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. 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