转换为boolean<br>
String支持的值为：true、false、yes、ok、no，1,0 如果给定的值为空，或者转换失败，返回默认值<br>
转换失败不会报错

@param value 被转换的值
@param defaultValue 转换错误时的默认值
@return 结果
198223
public static Boolean toBool(Object value, Boolean defaultValue) {
		return convert(Boolean.class, value, defaultValue);
	}
626377
def _parse_bool_default_value(property_name, default_value_string):
    """"""
    lowercased_value_string = default_value_string.lower()
    if lowercased_value_string in {'0', 'false'}:
        return False
    elif lowercased_value_string in {'1', 'true'}:
        return True
    else:
        raise AssertionError(u'Unsupported default value for boolean property "{}": '
                             u'{}'.format(property_name, default_value_string))
892472
public Option defaultValue(String defaultValue) throws RequiredParametersException {
		if (this.choices.isEmpty()) {
			return this.setDefaultValue(defaultValue);
		} else {
			if (this.choices.contains(defaultValue)) {
				return this.setDefaultValue(defaultValue);
			} else {
				throw new RequiredParametersException("Default value " + defaultValue +
						" is not in the list of valid values for option " + this.longName);
			}
		}
	}
263884
public boolean acceptsValue(String value) {
		if (value==null) {
			return false;
		} else if (hasValues()) {
			return getValuesList().contains(value);
		} else {
			return true;
		}
	}
370706
function parseBoolean(value, defaultValue) {
	const v = String(value).trim().toLowerCase();
	if ([ "true", "t", "1", "yes", "y" ].includes(v)) {
		return true;
	}
	else if ([ "false", "f", "0", "no", "n" ].includes(v)) {
		return false;
	}
	else {
		return defaultValue;
	}
}
1010806
public static Boolean toBoolean(Object o, Boolean defaultValue) {
	if (o instanceof Boolean) return ((Boolean) o);
	else if (o instanceof Number) return ((Number) o).intValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
	else if (o instanceof String) {
	    int rtn = stringToBooleanValueEL(o.toString());
	    if (rtn == 1) return Boolean.TRUE;
	    else if (rtn == 0) return Boolean.FALSE;
	    else {
		double dbl = toDoubleValue(o.toString(), Double.NaN);
		if (!Double.isNaN(dbl)) return toBooleanValue(dbl) ? Boolean.TRUE : Boolean.FALSE;
	    }

	}
	// else if(o instanceof Clob) return toBooleanValueEL(toStringEL(o));
	else if (o instanceof Castable) {
	    return ((Castable) o).castToBoolean(defaultValue);
	}
	else if (o instanceof ObjectWrap) return toBoolean(((ObjectWrap) o).getEmbededObject(defaultValue), defaultValue);

	else if (o == null) return toBoolean("", defaultValue);
	return defaultValue;
    }
930624
public boolean isMatched(String value, Boolean defaultValue)
    {
        // @todo: there isn't a defaultValue for radio button, what should we do here?
        if (value == null)
            return false;
        if (_match != null)
            return value.equals(_match);
        if (_defaultRadio != null)
            return value.equals(_defaultRadio);

        return false;
    }
870213
public <T> T eval(Object value, T defaultValue) {
        T result = null;
        if (value instanceof String) {
            String expression = (String) value;
            if (StringUtils.isNotBlank(expression)) {
                expression = expression.replaceAll("@\\{([^\\}]+)\\}", "\\${$1}");
                Class type = defaultValue != null ? defaultValue.getClass() : String.class;
                if (String.class.equals(type) && !expression.contains("${") && !expression.contains("#{")) {
                    result = (T) expression; // no change if it does not contain an actual EL expression
                } else {
                    ELContext elContext = getELContext();
                    ValueExpression valueExpression = createValueExpression(elContext, expression, type);
                    result = (T) valueExpression.getValue(elContext);
                }
            }
        }
        return result != null ? result : defaultValue;
    }
1020130
public static boolean isEmpty(String value) {
		int strLen;
		if (value == null || (strLen = value.length()) == 0) {
			return true;
		}
		for (int i = 0; i < strLen; i++) {
			if ((Character.isWhitespace(value.charAt(i)) == false)) {
				return false;
			}
		}
		return true;
	}
671216
public static String toStr(Object value, String defaultValue) {
		return convert(String.class, value, defaultValue);
	}
816178
boolean valuesAreTheSameAsDefault()
    {
        if (getDefaultValues() == null || getDefaultValues().size() == 0)
            return false;
        if (getValues() == null || getValues().size() == 0)
            return false;
        if (getDefaultValues().size() != getValues().size())
            return false;
        for (int v = 0; v < getDefaultValues().size(); v++)
            if (!getDefaultValues().get(v).equals(getValues().get(v)))
                return false;
        return true;
    }
316818
public static Boolean parseGeneralString(String str, Boolean defaultValue) {
		return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(str), defaultValue);
	}
721019
public String set(String value)
    {
        String prevValue = setString(value);
        if (prevValue == null) {
            prevValue = getDefaultValue();
        }
        return prevValue;
    }
116886
public static Character readCharacter(String value, Character defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Character.valueOf((char)Integer.parseInt(value));
	}
273894
public static Long getValue(final Long value, final Long defaultValue) {

    return value == null ? defaultValue : value;
  }
79880
public boolean containsValue(Object value) {
        value = maskNull(value);

        for (Object val : vals)
            if (value.equals(val))
                return true;

        return false;
    }
1256576
public static Boolean toNullableBoolean(Object value) {
		if (value == null)
			return null;
		if (value instanceof Boolean)
			return (boolean) value;
		if (value instanceof Duration)
			return ((Duration) value).toMillis() > 0;

		String strValue = value.toString().toLowerCase();
		if (strValue.equals("1") || strValue.equals("true") || strValue.equals("t") || strValue.equals("yes")
				|| strValue.equals("y"))
			return true;

		if (strValue.equals("0") || strValue.equals("false") || strValue.equals("f") || strValue.equals("no")
				|| strValue.equals("n"))
			return false;

		return null;
	}