@ComponentSpecification public interface ComposedValueConverter extends ValueConverter<Object,Object>, GenericValueConverter<Object>
ValueConverter that is composed out of individual
ValueConverters. The idea of this component is the idiom separations of concerns.
Therefore you can write an individual ValueConverter for each type of value you want to deal with.
These individual ValueConverters are combined to one generic converter following the
composition-pattern. Therefore this generic converter needs to choose the individual ValueConverter
that is appropriate for a specific conversion. source-type of the chosen ValueConverter
is assignable from the actual type of the
object to convert. Additionally the target-type of the chosen
ValueConverter needs to be assignable from the actual type to
convert to or vice versa. The following table illustrates this with some examples:| sourceType | targetType | ValueConverter |
applicable |
|---|---|---|---|
| String | Date | <String,Date> | yes |
| String | Date | <Object,Date> | yes |
| String | Date | <String,Calendar> | no |
| String | Number | <String,Integer> | yes |
| String | Integer | <String,Number> | yes |
| String | Integer | <String,Integer> | yes |
| Double | Integer | <String,Integer> | no |
| String | Double | <String,Integer> | no |
| * | * | <Object,Object> | yes |
| X | * | <? super X,Object> | yes |
| * | Y | <Object,? super Y> | yes |
| * | Y | <Object,? extends Y> | yes |
return null to indicate that conversion is NOT possible. This ComposedValueConverter
should therefore try all applicable converters starting from most to least specific until conversion
succeeds. If all applicable converters fail it will also fail and return null. DefaultComposedValueConverter.getInstance()convert, convert, getSourceType, getTargetTypeconvertValue, convertValue, convertValue, convertValue, convertValue, convertValueCopyright © 2001–2016 mmm-Team. All rights reserved.