com.hammurapi.convert

## Class ReflectionConverter<S,T>

- java.lang.Object
- - com.hammurapi.convert.ReflectionConverter<S,T>

- All Implemented Interfaces:
    AtomicConverter<S,T>

      public class ReflectionConverter<S,T>
      extends Object
      implements AtomicConverter<S,T>

  Converts one type to another using accessor/constructor combination.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReflectionConverter(Method accessor, Constructor<? extends T> constructor)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `convert(S source, Converter master, Context context, ClassLoader classLoader)` Converts object to target type.
    `static <T> Collection<ReflectionConverter<?,T>>` | `discoverConstructorConverters(Class<T> target)` Discovers constructor conversions.
    `Class<S>` | `getSourceType()`
    `Class<? extends T>` | `getTargetType()`
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### ReflectionConverter

          public ReflectionConverter(Method accessor,
                             Constructor<? extends T> constructor)

      Parameters:
        `accessor` - Source object method to invoke to get target type or constructor parameter for the target type. If it is null, then source itself is passed to constructor. One of parameters may be null, but not both.
        `constructor` - Target class constructor which takes one parameter, either source type or return type of source type accessor.

  - ### Method Detail

    - #### convert

          public T convert(S source,
                  Converter master,
                  Context context,
                  ClassLoader classLoader)

      Description copied from interface: `AtomicConverter`
      Converts object to target type.
      Specified by:
        `convert` in interface `AtomicConverter<S,T>`
      Parameters:
        `source` - Source object.
        `master` - Master converter to delegate conversion of object parts.
      Returns:
        Converted object.

    - #### getSourceType

          public Class<S> getSourceType()

      Specified by:
        `getSourceType` in interface `AtomicConverter<S,T>`
      Returns:
        Type which converter converts from.

    - #### getTargetType

          public Class<? extends T> getTargetType()

      Specified by:
        `getTargetType` in interface `AtomicConverter<S,T>`
      Returns:
        Type which converter converts to.

    - #### discoverConstructorConverters

          public static <T> Collection<ReflectionConverter<?,T>> discoverConstructorConverters(Class<T> target)

      Discovers constructor conversions.
      Parameters:
        `target` - Target type
      Returns:
        Collection of discovered converters.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`