All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.v7.data.util.converter.ReverseConverter Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * 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 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 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();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy