nz.co.senanque.vaadin.application.MaduraConverterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of madura-vaadin Show documentation
Show all versions of madura-vaadin Show documentation
Integrates Madura Objects with Vaadin applications including support for dynamic metadata changes (available choices, read/write status of fields etc).
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