Package org.apache.tapestry5.ioc.internal

## Class ValidatingMappedConfigurationWrapper<K,​V>

- java.lang.Object
- - org.apache.tapestry5.ioc.internal.AbstractConfigurationImpl<V>
  - - org.apache.tapestry5.ioc.internal.ValidatingMappedConfigurationWrapper<K,​V>

- Type Parameters:
    `K` - the key type
    `V` - the value type
  All Implemented Interfaces:
    `MappedConfiguration<K,​V>`

      public class ValidatingMappedConfigurationWrapper<K,​V>
      extends AbstractConfigurationImpl<V>
      implements MappedConfiguration<K,​V>

  A wrapper around a Map that provides the `MappedConfiguration` interface, and provides two forms of validation for mapped configurations:
  - If either key or value is null, then a warning is logged
  - If the key has previously been stored (by some other `ContributionDef`, then a warning is logged
  When a warning is logged, the key/value pair is not added to the delegate. Handles instantiation of instances.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ValidatingMappedConfigurationWrapper​(java.lang.Class<V> expectedValueType, ObjectLocator locator, TypeCoercerProxy typeCoercer, java.util.Map<K,​V> map, java.util.Map<K,​MappedConfigurationOverride<K,​V>> overrides, java.lang.String serviceId, ContributionDef contributionDef, java.lang.Class<K> expectedKeyType, java.util.Map<K,​ContributionDef> keyToContributor)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(K key, V value)` | Adds a keyed object to the service's contribution.
    `void` | `addInstance​(K key, java.lang.Class<? extends V> clazz)` | Adds a keyed object as an instantiated instance (with dependencies injected) of a class.
    `void` | `override​(K key, V value)` | Overrides an existing contribution by its key.
    `void` | `overrideInstance​(K key, java.lang.Class<? extends V> clazz)` | Overrides an existing contribution with a new instance.

    - ### Methods inherited from class org.apache.tapestry5.ioc.internal.AbstractConfigurationImpl

      `instantiate`

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

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

- - ### Constructor Detail

    - #### ValidatingMappedConfigurationWrapper

          public ValidatingMappedConfigurationWrapper​(java.lang.Class<V> expectedValueType,
                                                      ObjectLocator locator,
                                                      TypeCoercerProxy typeCoercer,
                                                      java.util.Map<K,​V> map,
                                                      java.util.Map<K,​MappedConfigurationOverride<K,​V>> overrides,
                                                      java.lang.String serviceId,
                                                      ContributionDef contributionDef,
                                                      java.lang.Class<K> expectedKeyType,
                                                      java.util.Map<K,​ContributionDef> keyToContributor)

  - ### Method Detail

    - #### add

          public void add​(K key,
                          V value)

      Description copied from interface: `MappedConfiguration`
      Adds a keyed object to the service's contribution.
      Specified by:
        `add` in interface `MappedConfiguration<K,​V>`
      Parameters:
        `key` - unique id for the value
        `value` - to contribute

    - #### addInstance

          public void addInstance​(K key,
                                  java.lang.Class<? extends V> clazz)

      Description copied from interface: `MappedConfiguration`
      Adds a keyed object as an instantiated instance (with dependencies injected) of a class. When the value type is an interface and the class to be contributed is a local file, then a reloadable proxy for the value class will be created and contributed.
      Specified by:
        `addInstance` in interface `MappedConfiguration<K,​V>`
      Parameters:
        `key` - unique id for the value
        `clazz` - class to instantiate and contribute

    - #### override

          public void override​(K key,
                               V value)

      Description copied from interface: `MappedConfiguration`
      Overrides an existing contribution by its key.
      Specified by:
        `override` in interface `MappedConfiguration<K,​V>`
      Parameters:
        `key` - unique id of value to override
        `value` - new value, or null to remove the key entirely

    - #### overrideInstance

          public void overrideInstance​(K key,
                                       java.lang.Class<? extends V> clazz)

      Description copied from interface: `MappedConfiguration`
      Overrides an existing contribution with a new instance. When the value type is an interface and the class to be contributed is a local file, then a reloadable proxy for the value class will be created and contributed.
      Specified by:
        `overrideInstance` in interface `MappedConfiguration<K,​V>`
      Parameters:
        `key` - unique id of value to override
        `clazz` - class to instantiate as override