|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@ComponentSpecification public interface ComposedValueConverter
This is the interface for a ValueConverter
that is composed out of
individual ValueConverter
s. 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 ValueConverter
s 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 |
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
.
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 |
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |