me.excel.tools.BooleanTranslator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-excel-tools Show documentation
Show all versions of java-excel-tools Show documentation
powerful and convenient excel tools
The newest version!
package me.excel.tools;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
/**
* translate human boolean to model value.
*
* Created by hanwen on 15-12-18.
*/
public class BooleanTranslator {
private BooleanTranslator() {
}
public static boolean parseBoolean(String value) {
if (isValidTrue(value)) {
return Boolean.TRUE;
} else if (isValidFalse(value)) {
return Boolean.FALSE;
}
return Boolean.parseBoolean(null);
}
public static boolean isValidTrue(String value) {
return ArrayUtils.contains(new String[]{"是", "yes", "y", "1", "true", "t"}, StringUtils.lowerCase(value));
}
public static boolean isValidFalse(String value) {
return ArrayUtils.contains(new String[]{"否", "no", "n", "0", "false", "f"}, StringUtils.lowerCase(value));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy