org.apache.tamaya.events

## Class PropertySourceChangeBuilder

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

-     public final class PropertySourceChangeBuilder
      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
    --- | ---
    `PropertySourceChangeBuilder` | `addChanges(org.apache.tamaya.spi.PropertySource newState)` This method records all changes to be applied to the base property provider/configuration to achieve the given target state.
    `PropertySourceChange` | `build()` Builds the corresponding change set.
    `static Collection<PropertyChangeEvent>` | `compare(org.apache.tamaya.spi.PropertySource map1, org.apache.tamaya.spi.PropertySource map2)` Compares the two property config/configurations and creates a collection current all changes that must be appied to render `map1` into `map2`.
    `PropertySourceChangeBuilder` | `deleteAll()` This method will create a change set that clears all entries fromMap the given base configuration/properties.
    `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 PropertySourceChangeBuilder` | `of(org.apache.tamaya.spi.PropertySource source, ChangeType changeType)` Creates a new instance of this builder.
    `PropertySourceChangeBuilder` | `putAll(Map<String,String> changes)` Apply all the given values to the base configuration/properties.
    `PropertySourceChangeBuilder` | `remove(String key, String... otherKeys)` Marks the given key(s) fromMap the configuration/properties to be removed.
    `void` | `reset()` Resets this change set instance.
    `PropertySourceChangeBuilder` | `setChangeType(ChangeType changeType)`
    `PropertySourceChangeBuilder` | `setTimestamp(long timestamp)`
    `PropertySourceChangeBuilder` | `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 PropertySourceChangeBuilder of(org.apache.tamaya.spi.PropertySource source,
                                       ChangeType changeType)

      Creates a new instance of this builder.
      Parameters:
        `source` - the underlying property provider/configuration, not null.
        `changeType` - kind of change.
      Returns:
        the builder for chaining.

    - #### compare

          public static Collection<PropertyChangeEvent> compare(org.apache.tamaya.spi.PropertySource map1,
                                                org.apache.tamaya.spi.PropertySource 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 PropertySourceChangeBuilder setVersion(String version)

    - #### setTimestamp

          public PropertySourceChangeBuilder setTimestamp(long timestamp)

    - #### addChanges

          public PropertySourceChangeBuilder addChanges(org.apache.tamaya.spi.PropertySource 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.

    - #### 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.

    - #### remove

          public PropertySourceChangeBuilder remove(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 PropertySourceChangeBuilder 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.

    - #### deleteAll

          public PropertySourceChangeBuilder deleteAll()

      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.

    - #### setChangeType

          public PropertySourceChangeBuilder setChangeType(ChangeType changeType)

    - #### build

          public PropertySourceChange 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.