org.apache.tamaya.integration.cdi.internal

## Class PropertyConverterManager

- java.lang.Object
- - org.apache.tamaya.integration.cdi.internal.PropertyConverterManager

-     @Vetoed
      public class PropertyConverterManager
      extends Object

  Manager that deals with `PropertyConverter` instances. This class is thread-safe.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PropertyConverterManager()` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected <T> org.apache.tamaya.spi.PropertyConverter<T>` | `createDefaultPropertyConverter(org.apache.tamaya.TypeLiteral<T> targetType)` Creates a dynamic PropertyConverter for the given target type.
    `Map<org.apache.tamaya.TypeLiteral<?>,List<org.apache.tamaya.spi.PropertyConverter<?>>>` | `getPropertyConverters()` Get a map of all property converters currently registered.
    `<T> List<org.apache.tamaya.spi.PropertyConverter<T>>` | `getPropertyConverters(org.apache.tamaya.TypeLiteral<T> targetType)` Get the list of all current registered converters for the given target type.
    `protected void` | `initConverters()` Registers the default converters provided out of the box.
    `boolean` | `isTargetTypeSupported(org.apache.tamaya.TypeLiteral<?> targetType)` Allows to evaluate if a given target type is supported.
    `<T> void` | `register(org.apache.tamaya.TypeLiteral<T> targetType, org.apache.tamaya.spi.PropertyConverter<T> converter)` Registers a ew converter instance.

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

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

- - ### Constructor Detail

    - #### PropertyConverterManager

          public PropertyConverterManager()

      Constructor.

  - ### Method Detail

    - #### initConverters

          protected void initConverters()

      Registers the default converters provided out of the box.

    - #### register

          public <T> void register(org.apache.tamaya.TypeLiteral<T> targetType,
                          org.apache.tamaya.spi.PropertyConverter<T> converter)

      Registers a ew converter instance.
      Type Parameters:
        `T` - the type.
      Parameters:
        `targetType` - the target type, not null.
        `converter` - the converter, not null.

    - #### isTargetTypeSupported

          public boolean isTargetTypeSupported(org.apache.tamaya.TypeLiteral<?> targetType)

      Allows to evaluate if a given target type is supported.
      Parameters:
        `targetType` - the target type, not null.
      Returns:
        true, if a converter for the given type is registered, or a default one can be created.

    - #### getPropertyConverters

          public Map<org.apache.tamaya.TypeLiteral<?>,List<org.apache.tamaya.spi.PropertyConverter<?>>> getPropertyConverters()

      Get a map of all property converters currently registered. This will not contain the converters that may be created, when an instance is adapted, which provides a String constructor or compatible factory methods taking a single String instance.
      Returns:
        the current map of instantiated and registered converters.
      See Also:
        `createDefaultPropertyConverter(TypeLiteral)`

    - #### getPropertyConverters

          public <T> List<org.apache.tamaya.spi.PropertyConverter<T>> getPropertyConverters(org.apache.tamaya.TypeLiteral<T> targetType)

      Get the list of all current registered converters for the given target type. If not converters are registered, they component tries to create and register a dynamic converter based on String costructor or static factory methods available.

      The converters provided are of the following type and returned in the following order:

      - Converters mapped explicitly to the required target type are returned first, ordered by decreasing priority. This means, if explicit converters are registered these are used primarly for converting a value.
      - The target type of each explicitly registered converter also can be transitively mapped to 1) all directly implemented interfaces, 2) all its superclasses (except Object), 3) all the interfaces implemented by its superclasses. These groups of transitive converters is returned similarly in the order as mentioned, whereas also here a priority based decreasing ordering is applied.
      - java.lang wrapper classes and native types are automatically mapped.
      - If no explicit converters are registered, for Enum types a default implementation is provided that compares the configuration values with the different enum members defined (cases sensitive mapping).

      So given that list above directly registered mappings always are tried first, before any transitive mapping should be used. Also in all cases @Priority annotations are honored for ordering of the converters in place. Transitive conversion is supported for all directly implemented interfaces (including inherited ones) and the inheritance hierarchy (exception Object). Super interfaces of implemented interfaces are ignored.

      Type Parameters:
        `T` - the type class
      Parameters:
        `targetType` - the target type, not null.
      Returns:
        the ordered list of converters (may be empty for not convertible types).
      See Also:
        `createDefaultPropertyConverter(TypeLiteral)`

    - #### createDefaultPropertyConverter

          protected <T> org.apache.tamaya.spi.PropertyConverter<T> createDefaultPropertyConverter(org.apache.tamaya.TypeLiteral<T> targetType)

      Creates a dynamic PropertyConverter for the given target type.
      Type Parameters:
        `T` - the type class
      Parameters:
        `targetType` - the target type
      Returns:
        a new converter, or null.

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