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

com.silentgo.utils.convertor.StringToBooleanConvertor Maven / Gradle / Ivy

There is a newer version: 0.1.16
Show newest version
package com.silentgo.utils.convertor;

import com.silentgo.utils.common.Const;
import com.silentgo.utils.inter.ITypeConvertor;

/**
 * Project : silentgo
 * com.silentgo.kit.typeconvert.support
 *
 * @author teddyzhu
 *         

* Created by teddyzhu on 16/8/20. */ public class StringToBooleanConvertor implements ITypeConvertor { @Override public Boolean convert(String source, Object... objects) { if (source == null) return null; if ((source.equalsIgnoreCase("true")) || (source.equalsIgnoreCase("on")) || (source.equalsIgnoreCase("yes"))) { return true; } else if ((source.equalsIgnoreCase("false")) || (source.equalsIgnoreCase("off")) || (source.equalsIgnoreCase("no"))) { return false; } else { throw new NumberFormatException("Parameter " + source + " can not be number"); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy