net.sf.mmm.util.value.api
Interface ComposedValueConverter

All Superinterfaces:
GenericValueConverter<Object>, SimpleValueConverter<Object,Object>, ValueConverter<Object,Object>
All Known Implementing Classes:
AbstractComposedValueConverter, ComposedValueConverterImpl, DefaultComposedValueConverter

@ComponentSpecification
public interface ComposedValueConverter
extends ValueConverter<Object,Object>, GenericValueConverter<Object>

This is the interface for a ValueConverter that is composed out of individual ValueConverters. The idea of this interface is the idiom separations of concerns. Therefore you can write an individual ValueConverter for each type of value you want to deal with.
The idea is to combine various individual ValueConverters 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.

The meaning of appropriate here can depend on the implementation. However it needs to guarantee that the 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

However the chosen converter may 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.

Since:
1.0.1
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Method Summary
 
Methods inherited from interface net.sf.mmm.util.value.api.ValueConverter
convert, convert, getSourceType, getTargetType
 
Methods inherited from interface net.sf.mmm.util.value.api.GenericValueConverter
convertValue, convertValue, convertValue, convertValue, convertValue, convertValue
 



Copyright © 2001-2010 mmm-Team. All Rights Reserved.