com.vaadin.v7.data.util.converter.ReverseConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-compatibility-server Show documentation
Show all versions of vaadin-compatibility-server Show documentation
Vaadin 7 compatibility package for Vaadin 8
/*
* Copyright (C) 2000-2024 Vaadin Ltd
*
* This program is available under Vaadin Commercial License and Service Terms.
*
* See for the full
* license.
*/
package com.vaadin.v7.data.util.converter;
import java.util.Locale;
/**
* A converter that wraps another {@link Converter} and reverses source and
* target types.
*
* @param
* The source type
* @param
* The target type
*
* @author Vaadin Ltd
* @since 7.0
*
* @deprecated As of 8.0, no direct replacement available.
*/
@Deprecated
public class ReverseConverter
implements Converter {
private Converter realConverter;
/**
* Creates a converter from source to target based on a converter that
* converts from target to source.
*
* @param converter
* The converter to use in a reverse fashion
*/
public ReverseConverter(Converter converter) {
this.realConverter = converter;
}
/*
* (non-Javadoc)
*
* @see com.vaadin.data.util.converter.Converter#convertToModel(java
* .lang.Object, java.util.Locale)
*/
@Override
public MODEL convertToModel(PRESENTATION value,
Class extends MODEL> targetType, Locale locale)
throws ConversionException {
return realConverter.convertToPresentation(value, targetType, locale);
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang
* .Object, java.util.Locale)
*/
@Override
public PRESENTATION convertToPresentation(MODEL value,
Class extends PRESENTATION> targetType, Locale locale)
throws ConversionException {
return realConverter.convertToModel(value, targetType, locale);
}
/*
* (non-Javadoc)
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
@Override
public Class getModelType() {
return realConverter.getPresentationType();
}
/*
* (non-Javadoc)
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
@Override
public Class getPresentationType() {
return realConverter.getModelType();
}
}