org.apache.tamaya.events

## Class ConfigurationChangeBuilder

- java.lang.Object
- - org.apache.tamaya.events.ConfigurationChangeBuilder

-     public final class ConfigurationChangeBuilder
      extends Object

  Models a set current changes applied to a `PropertySource`. Consumers of these events can observing changes to property sources and
  1. Check if their current configuration instance (`ConfigurationContext` contains the changed `PropertySource` (Note: the reference tova property source is never affected by a change, its only the data of the property source).
  2. If so corresponding action may be taken, such as reevaluating the configuration values (depending on the update policy) or reevaluating the complete `Configuration` to create a change event on configuration level.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConfigurationChangeBuilder` | `addChange(String key, String value)` Applies a single key/value change.
    `ConfigurationChangeBuilder` | `addChanges(org.apache.tamaya.Configuration newState)` This method records all changes to be applied to the base property provider/configuration to achieve the given target state.
    `ConfigurationChange` | `build()` Builds the corresponding change set.
    `static Collection<PropertyChangeEvent>` | `compare(org.apache.tamaya.Configuration map1, org.apache.tamaya.Configuration map2)` Compares the two property config/configurations and creates a collection current all changes that must be appied to render `map1` into `map2`.
    `String` | `get(String key)` Get the current values, also considering any changes recorded within this change set.
    `boolean` | `isEmpty()` Checks if the change set is empty, i.e. does not contain any changes.
    `static ConfigurationChangeBuilder` | `of()` Creates a new instance current this builder using the current COnfiguration as root resource.
    `static ConfigurationChangeBuilder` | `of(org.apache.tamaya.Configuration configuration)` Creates a new instance current this builder.
    `ConfigurationChangeBuilder` | `putAll(Map<String,String> changes)` Apply all the given values to the base configuration/properties.
    `ConfigurationChangeBuilder` | `removeAllKeys()` This method will create a change set that clears all entries fromMap the given base configuration/properties.
    `ConfigurationChangeBuilder` | `removeKey(String key, String... otherKeys)` Marks the given key(s) fromMap the configuration/properties to be removed.
    `void` | `reset()` Resets this change set instance.
    `ConfigurationChangeBuilder` | `setTimestamp(long timestamp)`
    `ConfigurationChangeBuilder` | `setVersion(String version)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### of

          public static ConfigurationChangeBuilder of()

      Creates a new instance current this builder using the current COnfiguration as root resource.
      Returns:
        the builder for chaining.

    - #### of

          public static ConfigurationChangeBuilder of(org.apache.tamaya.Configuration configuration)

      Creates a new instance current this builder.
      Parameters:
        `configuration` - the configuration changed, not null.
      Returns:
        the builder for chaining.

    - #### compare

          public static Collection<PropertyChangeEvent> compare(org.apache.tamaya.Configuration map1,
                                                org.apache.tamaya.Configuration map2)

      Compares the two property config/configurations and creates a collection current all changes that must be appied to render `map1` into `map2`.
      Parameters:
        `map1` - the source map, not null.
        `map2` - the target map, not null.
      Returns:
        a collection current change events, never null.

    - #### setVersion

          public ConfigurationChangeBuilder setVersion(String version)

    - #### setTimestamp

          public ConfigurationChangeBuilder setTimestamp(long timestamp)

    - #### addChanges

          public ConfigurationChangeBuilder addChanges(org.apache.tamaya.Configuration newState)

      This method records all changes to be applied to the base property provider/configuration to achieve the given target state.
      Parameters:
        `newState` - the new target state, not null.
      Returns:
        the builder for chaining.

    - #### addChange

          public ConfigurationChangeBuilder addChange(String key,
                                             String value)

      Applies a single key/value change.
      Parameters:
        `key` - the changed key
        `value` - the new value.
      Returns:
        this instance for chining.

    - #### get

          public String get(String key)

      Get the current values, also considering any changes recorded within this change set.
      Parameters:
        `key` - the key current the entry, not null.
      Returns:
        the keys, or null.

    - #### removeKey

          public ConfigurationChangeBuilder removeKey(String key,
                                             String... otherKeys)

      Marks the given key(s) fromMap the configuration/properties to be removed.
      Parameters:
        `key` - the key current the entry, not null.
        `otherKeys` - additional keys to be removed (convenience), not null.
      Returns:
        the builder for chaining.

    - #### putAll

          public ConfigurationChangeBuilder putAll(Map<String,String> changes)

      Apply all the given values to the base configuration/properties. Note that all values passed must be convertible to String, either
      - the registered codecs provider provides codecs for the corresponding keys, or
      - default codecs are present for the given type, or
      - the value is an instanceof String
      Parameters:
        `changes` - the changes to be applied, not null.
      Returns:
        the builder for chaining.

    - #### removeAllKeys

          public ConfigurationChangeBuilder removeAllKeys()

      This method will create a change set that clears all entries fromMap the given base configuration/properties.
      Returns:
        the builder for chaining.

    - #### isEmpty

          public boolean isEmpty()

      Checks if the change set is empty, i.e. does not contain any changes.
      Returns:
        true, if the set is empty.

    - #### reset

          public void reset()

      Resets this change set instance. This will clear all changes done to this builder, so the set will be empty.

    - #### build

          public ConfigurationChange build()

      Builds the corresponding change set.
      Returns:
        the new change set, never null.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2014–2016 Apache Software Foundation. All rights reserved.