Package de.gebit.integrity.parameter.conversion

## Class Conversion<FROM,​TO>

- java.lang.Object
- - de.gebit.integrity.parameter.conversion.Conversion<FROM,​TO>

- Type Parameters:
    `FROM` - the source type
    `TO` - the target type
  Direct Known Subclasses:
    `AbstractBooleanToString`, `AbstractBooleanValueToString`, `AbstractCalendarToString`, `AbstractCharacterToString`, `AbstractDateAndTimeValueToString`, `AbstractDateToString`, `AbstractDateValueToString`, `AbstractDecimalValueToString`, `AbstractEnumToString`, `AbstractEnumValueToString`, `AbstractFormattedStringToString`, `AbstractIntegerValueToString`, `AbstractJavaConstantConversion`, `AbstractMapToString`, `AbstractNestedObjectToString`, `AbstractNumberToString`, `AbstractObjectToString`, `AbstractRegexValueToString`, `AbstractStringToString`, `AbstractStringValueToString`, `AbstractTimeValueToString`, `BigDecimalToBigDecimal`, `BigIntegerToBigDecimal`, `BigIntegerToBigInteger`, `BooleanToBoolean`, `BooleanValueToBoolean`, `ByteToBigDecimal`, `ByteToByte`, `CalendarToDate`, `CalendarToInstant`, `CalendarToLocalDate`, `CalendarToLocalDateTime`, `CalendarToLocalTime`, `CalendarToSQLDate`, `CalendarToSQLTime`, `CalendarToTimestamp`, `CalendarToZonedDateTime`, `CharacterToBigDecimal`, `CharacterToBigInteger`, `CharacterToCharacter`, `DateAndTimeValueToCalendar`, `DateAndTimeValueToDate`, `DateAndTimeValueToInstant`, `DateAndTimeValueToLocalDate`, `DateAndTimeValueToLocalDateTime`, `DateAndTimeValueToLocalTime`, `DateAndTimeValueToSQLDate`, `DateAndTimeValueToSQLTime`, `DateAndTimeValueToTimestamp`, `DateAndTimeValueToZonedDateTime`, `DateToCalendar`, `DateToSQLDate`, `DateToSQLTime`, `DateToTimestamp`, `DateValueToCalendar`, `DateValueToDate`, `DateValueToInstant`, `DateValueToLocalDate`, `DateValueToLocalDateTime`, `DateValueToSQLDate`, `DateValueToSQLTime`, `DateValueToTimestamp`, `DateValueToZonedDateTime`, `DecimalValueToBigDecimal`, `DecimalValueToCharacter`, `DecimalValueToDouble`, `DecimalValueToFloat`, `DecimalValueToNumber`, `DoubleToBigDecimal`, `DoubleToDouble`, `EmptyValueToEmptyString`, `EmptyValueToFormattedString`, `EnumValueToEnumConstant`, `FloatToBigDecimal`, `FloatToFloat`, `InexistentValueToFormattedString`, `InexistentValueToInexistentString`, `IntegerToBigDecimal`, `IntegerToInteger`, `IntegerValueToBigDecimal`, `IntegerValueToBigInteger`, `IntegerValueToByte`, `IntegerValueToCharacter`, `IntegerValueToDouble`, `IntegerValueToFloat`, `IntegerValueToInteger`, `IntegerValueToLong`, `IntegerValueToNumber`, `IntegerValueToShort`, `LongToBigDecimal`, `LongToLong`, `MapToBean`, `MapToMap`, `NestedObjectToBean`, `NestedObjectToMap`, `NullValueToNull`, `NumberToBigInteger`, `NumberToByte`, `NumberToCharacter`, `NumberToDouble`, `NumberToFloat`, `NumberToInteger`, `NumberToLong`, `NumberToShort`, `ObjectToMap`, `ObjectToObject`, `OptionalToContainedObject`, `OptionalToFormattedString`, `PatternToPattern`, `RegexValueToPattern`, `ShortToBigDecimal`, `ShortToShort`, `SQLDateToCalendar`, `SQLDateToTimestamp`, `SQLTimeToCalendar`, `SQLTimeToTimestamp`, `StringToBigDecimal`, `StringToBigInteger`, `StringToByte`, `StringToCharacter`, `StringToDouble`, `StringToEnumConstant`, `StringToFloat`, `StringToInteger`, `StringToLong`, `StringToNumber`, `StringToPattern`, `StringToShort`, `StringValueToBigDecimal`, `StringValueToBigInteger`, `StringValueToBoolean`, `StringValueToByte`, `StringValueToCharacter`, `StringValueToDouble`, `StringValueToEnumConstant`, `StringValueToFloat`, `StringValueToInteger`, `StringValueToLong`, `StringValueToNumber`, `StringValueToPattern`, `StringValueToShort`, `TimestampToCalendar`, `TimeValueToCalendar`, `TimeValueToDate`, `TimeValueToInstant`, `TimeValueToLocalDateTime`, `TimeValueToLocalTime`, `TimeValueToSQLDate`, `TimeValueToSQLTime`, `TimeValueToTimestamp`, `TimeValueToZonedDateTime`, `TypedNestedObjectToBean`, `TypedNestedObjectToFormattedString`, `TypedNestedObjectToMap`, `TypedNestedObjectToString`

      public abstract class Conversion<FROM,​TO>
      extends Object

  A `Conversion` defines a transformation from one type into another.
  Author:
    Rene Schneider - initial API and implementation

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `Conversion.Priority` | Add this annotation to a `Conversion` implementation to set the priority of this conversion.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Conversion()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract TO` | `convert​(FROM aSource, Class<? extends TO> aTargetType, ConversionContext aConversionContext)` | Performs the conversion.
    `protected Object` | `convertValueRecursive​(Class<?> aTargetType, Class<?> aParameterizedType, Object aValue, ConversionContext aConversionContext)` | Recursively converts the given value to the defined target type.
    `protected FormattedString[]` | `convertValueToFormattedStringArrayRecursive​(Object aValue, ConversionContext aConversionContext)` | Recursively converts the given value to a string array.
    `void` | `setVisitedObjects​(Set<Object> someVisitedObjects)` |

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

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

- - ### Constructor Detail

    - #### Conversion

          public Conversion()

  - ### Method Detail

    - #### convert

          public abstract TO convert​(FROM aSource,
                                     Class<? extends TO> aTargetType,
                                     ConversionContext aConversionContext)
                              throws ConversionFailedException

      Performs the conversion.
      Parameters:
        `aSource` - the source object to convert
        `aTargetType` - TODO
        `aConversionContext` - controls some conversion parameters and rules; may be null if the default `ConversionContext` values shall be used
      Returns:
        the converted object
      Throws:
        `ConversionFailedException` - in case of conversion errors

    - #### setVisitedObjects

          public void setVisitedObjects​(Set<Object> someVisitedObjects)

    - #### convertValueRecursive

          protected Object convertValueRecursive​(Class<?> aTargetType,
                                                 Class<?> aParameterizedType,
                                                 Object aValue,
                                                 ConversionContext aConversionContext)
                                          throws ParameterUtil.UnresolvableVariableException,
                                                 ClassNotFoundException,
                                                 UnexecutableException,
                                                 InstantiationException

      Recursively converts the given value to the defined target type. This method provides implicit protection against endless recursion loops.
      Parameters:
        `aTargetType` - the target type
        `aParameterizedType` - the parameterized type in case of generics
        `aValue` - the value to convert
        `aConversionContext` - some parameters controlling the conversion (if null, a default context is used)
      Returns:
        the converted value
      Throws:
        `ParameterUtil.UnresolvableVariableException`
        `ClassNotFoundException`
        `UnexecutableException`
        `InstantiationException`

    - #### convertValueToFormattedStringArrayRecursive

          protected FormattedString[] convertValueToFormattedStringArrayRecursive​(Object aValue,
                                                                                  ConversionContext aConversionContext)

      Recursively converts the given value to a string array. This method provides implicit protection against endless recursion loops.
      Parameters:
        `aValue` - the value to convert
        `aConversionContext` - some parameters controlling the conversion (if null, a default context is used)
      Returns:
        the converted string array