MODEL
- The source typePRESENTATION
- The target typepublic class ReverseConverter<PRESENTATION,MODEL> extends Object implements Converter<PRESENTATION,MODEL>
Converter
and reverses source and
target types.Converter.ConversionException
Constructor and Description |
---|
ReverseConverter(Converter<MODEL,PRESENTATION> converter)
Creates a converter from source to target based on a converter that
converts from target to source.
|
Modifier and Type | Method and Description |
---|---|
MODEL |
convertToModel(PRESENTATION value,
Class<? extends MODEL> targetType,
Locale locale)
Converts the given value from target type to source type.
|
PRESENTATION |
convertToPresentation(MODEL value,
Class<? extends PRESENTATION> targetType,
Locale locale)
Converts the given value from source type to target type.
|
Class<MODEL> |
getModelType()
The source type of the converter.
|
Class<PRESENTATION> |
getPresentationType()
The target type of the converter.
|
public ReverseConverter(Converter<MODEL,PRESENTATION> converter)
converter
- The converter to use in a reverse fashionpublic MODEL convertToModel(PRESENTATION value, Class<? extends MODEL> targetType, Locale locale) throws Converter.ConversionException
Converter
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)
and
Converter.convertToModel(Object, Class, Locale)
should return the original
value.convertToModel
in interface Converter<PRESENTATION,MODEL>
value
- The value to convert, compatible with the target type. Can be
nulltargetType
- The requested type of the return valuelocale
- The locale to use for conversion. Can be null.Converter.ConversionException
- If the value could not be convertedpublic PRESENTATION convertToPresentation(MODEL value, Class<? extends PRESENTATION> targetType, Locale locale) throws Converter.ConversionException
Converter
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)
and
Converter.convertToModel(Object, Class, Locale)
should return the original
value.convertToPresentation
in interface Converter<PRESENTATION,MODEL>
value
- The value to convert, compatible with the target type. Can be
nulltargetType
- The requested type of the return valuelocale
- The locale to use for conversion. Can be null.Converter.ConversionException
- If the value could not be convertedpublic Class<MODEL> getModelType()
Converter
Converter.convertToPresentation(Object, Class, Locale)
.getModelType
in interface Converter<PRESENTATION,MODEL>
public Class<PRESENTATION> getPresentationType()
Converter
Converter.convertToModel(Object, Class, Locale)
.getPresentationType
in interface Converter<PRESENTATION,MODEL>
Copyright © 2019 Vaadin Ltd. All rights reserved.