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

it.espr.mvc.converter.StringToBooleanConverter Maven / Gradle / Ivy

There is a newer version: 0.3.4
Show newest version
package it.espr.mvc.converter;

import it.espr.injector.Utils;

public class StringToBooleanConverter extends AStringToCastingConverter {

	@Override
	public Class getType() {
		return Boolean.class;
	}

	@Override
	public Boolean convert(String value) throws StringToTypeConverterException {
		try {
			if (!Utils.isEmpty(value)) {
				if ("1".equals(value)) {
					return true;
				}
				return Boolean.valueOf(value);
			}
		} catch (Exception e) {
			throw new StringToTypeConverterException("Couldn't parse value '" + value + "'", e);
		}
		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy