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

nz.co.senanque.vaadin.application.MaduraConverterFactory Maven / Gradle / Ivy

Go to download

Integrates Madura Objects with Vaadin applications including support for dynamic metadata changes (available choices, read/write status of fields etc).

There is a newer version: 3.4.1
Show newest version
package nz.co.senanque.vaadin.application;

import java.math.BigDecimal;

import org.springframework.stereotype.Component;

import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.DefaultConverterFactory;

/**
 * Provides an injectable way to get the correct {link com.vaadin.data.util.converter.Converter}.
 * Also adds specialised converters to handle decimals.
 * 
 * @author Roger Parkinson
 *
 */
@Component("maduraConverterFactory")
public class MaduraConverterFactory extends DefaultConverterFactory {

	protected  Converter findConverter(
			Class presentationType, Class modelType) {

		Converter ret = super.findConverter(
				presentationType, modelType);

		return ret;
	}

    protected Converter createStringConverter(Class sourceType) {
        if (Double.class.isAssignableFrom(sourceType) || Double.TYPE == sourceType) {
            return new MaduraStringToDoubleConverter();
        } else if (Float.class.isAssignableFrom(sourceType) || Float.TYPE == sourceType) {
            return new MaduraStringToFloatConverter();
        } else if (BigDecimal.class.isAssignableFrom(sourceType)) {
            return new MaduraStringToBigDecimalConverter();
        } else {
            return super.createStringConverter(sourceType);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy